Index as table sort by column might fail when paging
When sorting on a column having many records pr distinct value in that column going through all records using paging in the index page all records might not be shown.
This is because each page runs a new query in which it sorts by the column and uses offset and limit to find the page. If there are more records with the same value in the column being sorted by their order within the result is not defined and can thus change from page to page resulting in some records not being shown and some being shown twice or more (on separate pages).
The solution is to always sort by primary key after sorting by the column: select records.* from records order by sorting_column, id;
Is there any patch for this issue? I'm facing the same and seems to be very common problem.
Hard to understand the message but if right, this is an expected issue with a Postgres database where you must order by a column where each value is unique for the order to be predictable, otherwise if values are the same then that order can be essentially random. I believe this to be the issue. I would be open to a PR that whenever sorting by a column, if its not the primary key, we add the primary key to the end.