Answer the question
In order to leave comments, you need to log in
How to make quick pagination sorted by date?
Greetings.
You need to do a quick pagination on the comments table on the site by date
There are only 450 thousand comments in the
table Table of the form
id - int|comment - varchar|dt - date
Page selection
SELECT * FROM comment order by dt desc LIMIT 50 OFFSET {page*50}
Answer the question
In order to leave comments, you need to log in
offhand
Where LAST_COMMENT_INDEX is the index of the last comment from the previous page
mysql on large volumes can ignore string indexes (yes, datetime index is string in general). There are 2 options:
- try to make an index on a separate field with unix_timestamp (with int everything should work in theory)
- put all the fields that you receive in the query into the index (then you will not leave him a choice, but the index will be much more heavy)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question