News for hackers. Stuff that matters.
Re:Phoenix LiveView 1.0.0 is here by ethbr1 on Tuesday December 03, 2024 @08:24PM (#42313618)
How does pagination in urls work nowadays? You'd need ~3 bytes to index a reasonable number of pages naively, no?

But curious what current art is re: performance optimizations between frontend and backend. Or is it simply page indices?

Re:Phoenix LiveView 1.0.0 is here by out_of_protocol on Wednesday December 04, 2024 @05:22AM (#42316136)
If you do limit/offset on database side, page number is enough. Though this doesn't work well for bigger page numbers. There's other ways to do pagination, e.g. with "cursors", where cursor is simply id of last record on previous page. SQL query is very efficient, but jumping to page X is impossible. In this scenario storing cursors for past pages is needed
Re:Phoenix LiveView 1.0.0 is here by cess11 on Wednesday December 04, 2024 @05:34AM (#42316210)
There are libraries for Ecto that help with this.

https://github.com/duffelhq/paginator

Re:Phoenix LiveView 1.0.0 is here by sph on Wednesday December 04, 2024 @08:23AM (#42317180)
Careful that this library last I used it (2020 or so) used a particularly insecure encoding of the cursor that basically allows remote execution. Not sure if they ever addressed it.

Here's the fork I created at the time to work around some of these issues: https://github.com/1player/paginator

Re:Phoenix LiveView 1.0.0 is here by cess11 on Thursday December 05, 2024 @02:57AM (#42325978)
Thanks for pointing that out.
Re:Phoenix LiveView 1.0.0 is here by ethbr1 on Thursday December 05, 2024 @08:52AM (#42328218)
Thanks to thread for the informative responses! (And the useful README on your fork/the upstream)

I try to assume someone's thought of better than the best I could, or at least learned the hard way what edge cases need to be handled.

Re:Phoenix LiveView 1.0.0 is here by gregors on Friday December 13, 2024 @08:53AM (#42408407)