Hello all
I have a query like this where I want to display sorted records in a paginated format.
This is my query.
SELECT * FROM answers
WHERE userid = '10'
ORDER BY votes LIMIT 10, 20
The two arguments to LIMIT
will be used for generating page-by-page display of records. Now, my problem is ORDER BY
. How does MySQL execute this query?
1st way
- Select the records according to filters
- Sort them
- Limit them
2nd way
- Select the records according to filters
- Limit them
- Sort them
If I think like MySQL engine, I would want to implement 2nd, since I would then have to sort lesser records?
Can somebody throw some light on this?
Regards