MrFish Posted January 7, 2010 Report Share Posted January 7, 2010 If I have a code that regularly searches a database with tens of thousands of entries (lets say it's a users database) would it be quicker to search by INT or VARCHAR or does it matter? SELECT * FROM users WHERE id=6468 or SELECT * FROM users WHERE username='testuser' I would imagine that the first would be much quicker. Link to comment Share on other sites More sharing options...
justsomeguy Posted January 7, 2010 Report Share Posted January 7, 2010 An int is generally quicker to search on, but both will be fast if they are both indexed. It will be fastest if you search on the primary key. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now