Answer the question
In order to leave comments, you need to log in
How to optimize SQL query with ORDER BY?
When using ORDER BY to sort by date, the query execution increases by 10 times.
SELECT * FROM comments c INNER JOIN users u ON c.login = u.login ORDER BY c.date DESC LIMIT 5
Answer the question
In order to leave comments, you need to log in
indexes on both tables on login , then play with composite index login + date or just date
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question