• Welcome to Valhalla Legends Archive.
 

database searching

Started by Noodlez, March 16, 2003, 10:45 AM

Previous topic - Next topic

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

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

Grok

#2
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.

Banana fanna fo fanna

#3
I told you you should use a hash table!