Valhalla Legends Forums Archive | General Programming | database searching

AuthorMessageTime
Noodlez
Say I have a database with 10,000 people in it... What would be the fastest way to search through it and find a given username (assuming every username in it is unique)

If I can't find a reasonably fast way I guess ill just have to use something like MySQL and do Select <USERNAME> * from users
March 16, 2003, 4:45 PM
Yoni
Depends on the format of the database.

If it's not sorted, you'll have to go from beginning to end.

A database that is built to handle a large amount of entries should be sorted for best efficiency. In a sorted database, you can usually use a binary search (or searching down a binary tree) which is much faster than a linear search.

Also, you can use a hashtable for the fastest searching.

Try your luck on: www.google.com
March 16, 2003, 5:13 PM
Grok
Do exactly like you said .. MySQL, make username an index to the table, and whether unique or not, "SELECT * FROM USERS WHERE USERNAME='GROK'" will return you the row faster than anything you can write with your experience level.
March 16, 2003, 7:30 PM
St0rm.iD
I told you you should use a hash table!
March 16, 2003, 11:45 PM

Search