I have a table that is constantly being added to various user names. I have a page that a user can download that shows the most recent entry in the database that they submitted.
An example of the query I use: SELECT timestamp FROM entry_list WHERE username = 'user' ORDER BY entry_id DESC LIMIT 1
The table has an index with two columns: username, timestamp. This index is used as requested by EXPLAIN with the following additional information:
select_type: SIMPLE
Type: ref
key_len: 34
ref: const
lines: 5654
Optional: use where; Index usage; Using filesort
How can I optimize my query? This is pretty fast for a single user (0.2 ~ 0.4 sec), but some accounts download this information for 5, 10 or even 20 different users at the same time. Even 0.2 ~ 0.4 seems a little long, and when it ends up slowing down the page loading by 4-8 seconds, this is unacceptable.
source
share