4 ms·
how to jump to an arbitrary page?
by dinkledunk 4y ago
how to jump to an arbitrary page?
- jsmith99 4y agoDo you really need to jump to an arbitrary page and land on the exact item? For many applications an approximate jump is fine. If your column is fairly uniformly distributed you can guess the index for any arbitrary page.
- dinkledunk 4y agoYes, my business users will feel like they don't have sufficient access to their data if they can't. > If your column is fairly uniformly distributed you can guess the index for any arbitrary page. I don't think that'll work in a multi-tenancy situation with complex filters.
- waspight 4y agoI bet your users does not always know what is best for them.
- eurasiantiger 4y agoSome people thoroughly enjoy a linear saccade search! See for example any social media app. It definitely isn’t in the users’ best interest to have any method of scrolling through a lot of records.
- hnuser847 4y agoSpoiler: you can’t.
- thaumasiotes 4y agoBut the entire concept is that this is an adaptation to the fact that data may be added to or removed from the database. If that's true, there would be no benefit in jumping to a specific page - there's no guarantee that that page will display any particular data.
- MatmaRex 4y agoYou don't, but instead you can jump to an arbitrary place in the results. For example, you could show results starting from the letter P, or show results starting from 2022-04-02.
- squeaky-clean 4y agoJumping to a specific page is a bit of an ambiguous / undefined term in this case. Like asking for a specific page in a book that's still being written. Maybe today the plot twist occurred on page 100, but then the author decides chapter 1 needs more backstory, and now the plot twist happens on page 115. Unless you can guarantee your data is static, or that the sorting order cannot be mutated and only append later values, the concept of what data belongs in which page could be changing every millisecond.
- nextaccountic 4y agoYou can do that with postgres histograms https://www.citusdata.com/blog/2016/03/30/five-ways-to-paginate/ https://www.citusdata.com/blog/2016/03/30/five-ways-to-pagin... - go to the section "Keyset with Estimated Bookmarks" > As we saw, plain keyset pagination offers no facility to jump a certain percentage into the results except through client guesswork. However the PostgreSQL statistics collector maintains per-column histograms of value distribution. We can use these estimates in conjunction with limits and small offsets to get fast random-access pagination through a hybrid approach.