Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I implement binary search using MySQL?

I know the basic concepts of binary search and binary insertion sort, but how can I use that knowledge with MySQL? How do I query to find a username in 1000 alphabetized rows and how do I query to insert a username?

like image 531
user2896120 Avatar asked Mar 01 '26 11:03

user2896120


1 Answers

You don't. You index the column and let the database use whatever algorithm it chooses for the index. This will probably be a B+-tree, which is much more efficient than a binary search when the data is on a disk.

like image 183
user207421 Avatar answered Mar 03 '26 04:03

user207421



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!