MrFish Posted January 7, 2010 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 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
Archived
This topic is now archived and is closed to further replies.