M
M
mark_me2019-09-09 07:42:55
MySQL
mark_me, 2019-09-09 07:42:55

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

Maybe I'm using ORDER BY somehow wrong.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Northern Lights, 2019-09-09
@mark_me

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 question

Ask a Question

731 491 924 answers to any question