2 ms·
You can only do it on the index, the query from the index will return in the sort order. You have to be very careful in your index and query design to make this
by rythie 17y ago
You can only do it on the index, the query from the index will return in the sort order. You have to be very careful in your index and query design to make this work.
For example if your index is (username, date_posted) then you can do something like
SELECT * FROM table WHERE username='user' ORDER BY date_posted
but if you do
SELECT * FROM table WHERE username IN ('user','user2') ORDER BY date_posted
then it will need a temporary table.
You could change your index to (date_posted, username) to make it work, but then it will be slow when querying a small percent of the users.