Valhalla Legends Archive

Programming => General Programming => Topic started by: Noodlez on March 16, 2003, 10:45 AM

Title: database searching
Post by: Noodlez on March 16, 2003, 10:45 AM
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
Title: Re: database searching
Post by: Yoni on March 16, 2003, 11:13 AM
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
Title: Re: database searching
Post by: Grok on March 16, 2003, 01:30 PM
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.
Title: Re: database searching
Post by: Banana fanna fo fanna on March 16, 2003, 05:45 PM
I told you you should use a hash table!