Reputation: 413
If we give a query:
select name from employee where id=23102 and sir_name="raj";
I want to know using which algorithm this search will happen?
Upvotes: 7
Views: 4758
Reputation: 53603
Assuming you have indexed the id field and it is unique.
The algorithm is a binary search (there are optimizations and improvements, but below is the general theory behind it).
Lets say you have the following ordered list of numbers:
1,45,87,111,405,568,620,945,1100,5000,5102,5238,5349,5520
Say you want to search for number 5000, There are two ways.
That was 4 operation against 10, so, binary search complexity will grow at the same rate as full scan when in binary search data grows exponentially
Upvotes: 10
Reputation: 10350
You can use explain and procedure analyse to find out how your query is being run by mysql.
If you want to know what kind of algorithm it internally uses to find the resulting set. I'd suggest you read up on how DBMS work.
Upvotes: 0
Reputation: 135021
Indexes are stored as B-trees
in MySQL, Indexes on spatial data types use R-trees
, MEMORY tables also support hash indexes
.
Upvotes: 2