Tables and its details
“user” table stores user details and have 10 millions record
How much time does a query like this take ?
select * from user where user_name = "Jhon"
select * from user where uid = "2331234534"
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
if you want the query to run with max speed, ensure you have indexes on “user_name” and “uid” and just in case you can add LIMIT 1 at the end of each of them
they should return result almost instantly with indexes – way below 1 second.
UPDATE about indexes:
A very good explanation how indexes work is comparison to a library. If you have huge library with millions of books and you do not have indexes, whenever someone search for a certain book, you need to go through all bookshelfs. If you have indexes, you know that this book is in this certain place and you just go there and take it. That is why it really doesn’t matter that much if you have 1 million or 10 millions or 20 millions. Of course at some point you will have to reduce the size of the table but don’t be worried at all
UPDATE about indexing all fields:
you should not index all columns. The reason why is as follows: it is always tradeoff. Indexes speeds up READING from the database greatly, but they slow WRITING to it. Everytime you add a row to the database, index list must be refreshed – that is why you should index only collumns you really need to be indexed