Someone on quora asked:
How many searches does it take on average to find a row when not indexed in MySQL database?
When there is no index in use, you are essentially performing a sequential search (iterating through each row and testing it to see if it matches your criteria), which means the search performs at O(n). If you limit your results to the first hit (using TOP 1 as pointed out by Scott Berry), the average number of checks is n/2 where n is the total size of the sample set. If there is no limit, the average number of checks is n (since you check all rows)
If you enjoyed my content for some reason, I'd love to hear from you! Here are some options:
- You can buy me a coffee!
- You can write a reply on your own site and submit the URL as a webmention via the form below.
- Or you can just contact me!