which algorithm does mysql use to search an row in the table? -


like give query: select name employee id=23102 , sir_name="raj"; want know using algorithm search happen?

assuming have indexed id field , unique.
algorithm binary search (there optimizations , improvements, below general theory behind it).

lets have following ordered list of numbers:
1,45,87,111,405,568,620,945,1100,5000,5102,5238,5349,5520

say want search number 5000, there 2 ways.

  1. scan entire list, in case have check 10 numbers (count start until reach 5000).
  2. binary -> here steps: 2a. go middle number (620), since 5000 bigger that->
    2b. same on numbers 945-5520, median 5102 since 5000 smaller that->
    2c. go median of part 945-5102, 1100 since lower 5000 go part between 1100-5102
    2d. found it!

that 4 operation against 10, so, binary search complexity grow @ same rate full scan when in binary search data grows exponentially


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -