12 ms·
Off topic but does this not effect the Pagination functionality of databases as well? Using primary keys to skip first N pages and then limit the count of resul
by abhishekjha 7y ago
Off topic but does this not effect the Pagination functionality of databases as well? Using primary keys to skip first N pages and then limit the count of results seems to be the suggested way for getting items for the Nth page. If primary key is not monotonic then this is going to give jumbled results thus messing up results in the Nth page.
EDIT: More context for the above process[1]
[1]https://www.eversql.com/faster-pagination-in-mysql-why-order-by-with-limit-and-offset-is-slow/ https://www.eversql.com/faster-pagination-in-mysql-why-order...
- siscia 7y agoHummm, not sure I follow but most likely no. What parent mean is that there may be holes in the sequence of primary keys. What you do with pagination is that you first sort the sequence, then thrown away the first N results, and finally select only the next M results. It will work just fine.
- abhishekjha 7y agoI have linked the article for the above process.
- felixyz 7y agoThat is one way, not necessarily the most efficient. And having gaps in the id sequence can complicate pagination. Recommended reading: https://www.citusdata.com/blog/2016/03/30/five-ways-to-paginate/ https://www.citusdata.com/blog/2016/03/30/five-ways-to-pagin...
- quietbritishjim 7y ago> What parent mean is that there may be holes in the sequence of primary keys. Are you sure that's what they mean? It's not what they said. "Monotonic" means "strictly increasing" (or decreasing) e.g. 1, 2, 5, 7 is monotonic even though it has gaps. "Contiguous" means "without gaps".