Recently, I have a developed a very simple web app for a survey. I am using MySQL to store my data. Each user gets one question “randomly” drawn from the database table. I need to know if indexing would help to increase the retrieval performance while “SELECT” chooses random records each time.
thanks
This is the SQL command I am using:
'SELECT * FROM iens2.review_phrases ORDER BY RAND() LIMIT 1'
If your “random” number is the sequence number of a question’s sequence column (without gaps), then indexing that sequence column is certainly helping:
If, however you just
Then an index can’t help. With
An index on the order by clause’s field will help a little, but the performance is still worse than accessing your question by sequence number