Pagination return last record as first for next page

Im using Sorting - Skip - Limit in this order only (sorting desc)
Sometimes pagination returns the last record of that page, as 1st record of next page.

Its completely random.
Tried with raw queries and mongo Compass also getting same issue

example :

Hello, welcome to the MongoDB community.

When you sort a field that consists of repeated values, you must specify a field that is unique together. Add a unique field to the classification field, this will resolve the issue.

On the other hand, depending on the size of your dataset, skip/limit can become a problem. I would advise you to use keyset or a cursor for paging.

I’m available.

1 Like