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?
In the second statement, the LIKE value is not a constant. If you use ... LIKE '% string %' and string is longer than three characters, MySQL uses the Turbo Boyer-Moore algorithm to initialize the pattern for the string and then uses this pattern to perform the search more quickly.
MySQL SELECT statement is used to retrieve rows from one or more tables. The statement can also include UNION statements and subqueries. SELECT statement is used to fetch rows or records from one or more tables.
The algorithm is a binary search (there are optimizations and improvements, but below is the general theory behind it). Say you want to search for number 5000, There are two ways. scan the entire list, in which case you will have to check 10 numbers (count from start until you reach 5000). 2d.
MySQL can perform boolean full-text searches using the IN BOOLEAN MODE modifier. With this modifier, certain characters have special meaning at the beginning or end of words in the search string. Characteristics of Boolean Full-Text searches : Do not use the 50% threshold that applies to MyISAM search indexes.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With