1

What if I had a PHP script that had a pagination that loads last 10 rows then page two loaded next 10 in DESC order, but before loading next 10 on page 2, other 10 rows were added to the table?
What would happen?

And if the same 10 rows were to be loaded again, and I had a TIMESTAMP column in my table, how would I take that to my vantage to avoid that scenario?

Thanks.

  • 1
    You may want to provide the table structure and the query you use. – mustaccio Feb 11 at 3:00
  • The second query is uncorrelated with the first. Be specific with sample data, table structure, query, adding new data, and expected output (on both pages). – danblack Feb 11 at 4:55
1

And that is one of 3 problems with using OFFSET for "pagination".

The other two are

  • What is some rows were deleted?
  • Performance.

The solution to all of them is to "remember where you left off". Here is my blog on the issues.

Most people who use OFFSET come to this forum bemoaning poor performance. Not many have (yet) discovered the "bug" you are pointing out.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.