▲ -4 ▼ Why You Shouldn’t Use OFFSET and LIMIT For Your Pagination (ivopereira.net) submitted 2 years ago* (last edited 2 years ago) by starman@programming.dev to c/programming@programming.dev 17 comments fedilink hide all child comments If you are wondering why lemmy is moving away from offset pagination since 0.19, here is a nice article about it
[–] SpaceNoodle@lemmy.world 15 points 2 years ago (2 children) Paywall. permalink fedilink source hideshow 4 child comments replies: [–] wccrawford@lemmy.world 10 points 2 years ago (4 children) https://ivopereira.net/efficient-pagination-dont-use-offset-limit This seems to be the same article. I have my doubts about the technique, but it could be useful in certain controlled situations. permalink fedilink source parent hideshow 8 child comments replies: [–] Max_P@lemmy.max-p.me 6 points 2 years ago Lemmy just implemented it for 0.19 and it makes a big difference on heavier queries like Scaled homepage. It also has the advantage of your pagination not getting screwy if new content has been added between page 2 and 3 queries. permalink fedilink source parent [–] MegaMacSlice@programming.dev 3 points 2 years ago (1 child) I was going to recommend looking at https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#scroll-search-results - but it looks like that method is now not advised- but if you read up above it it looks like there’s a search_after/PIT method described which sounds similar to the article. This is all to say - I don’t think this is a one-off concept - it’s been around for a bit. permalink fedilink source parent hideshow 2 child comments replies: [+] vzq@lemmy.blahaj.zone 1 point 2 years ago [deleted] permalink fedilink source parent [–] SpaceNoodle@lemmy.world 1 point 2 years ago Thanks! Agreed, it's a very limited usecase. permalink fedilink source parent [–] vzq@lemmy.blahaj.zone 1 point 2 years ago I have my doubts about the technique, but it could be useful in certain controlled situations This is completely uncontroversial advice and has been for 30 years. What are your doubts exactly? I’d go further: if you see a query that uses “offset” on a non-trivial production DB something is very, very wrong. Of course, the trick is that you need to make sure you have indexes for all sort orders you need to display, but that’s obvious. permalink fedilink source parent [–] starman@programming.dev [S] 1 point 2 years ago Sorry, I updated the link permalink fedilink source parent
[–] wccrawford@lemmy.world 10 points 2 years ago (4 children) https://ivopereira.net/efficient-pagination-dont-use-offset-limit This seems to be the same article. I have my doubts about the technique, but it could be useful in certain controlled situations. permalink fedilink source parent hideshow 8 child comments replies: [–] Max_P@lemmy.max-p.me 6 points 2 years ago Lemmy just implemented it for 0.19 and it makes a big difference on heavier queries like Scaled homepage. It also has the advantage of your pagination not getting screwy if new content has been added between page 2 and 3 queries. permalink fedilink source parent [–] MegaMacSlice@programming.dev 3 points 2 years ago (1 child) I was going to recommend looking at https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#scroll-search-results - but it looks like that method is now not advised- but if you read up above it it looks like there’s a search_after/PIT method described which sounds similar to the article. This is all to say - I don’t think this is a one-off concept - it’s been around for a bit. permalink fedilink source parent hideshow 2 child comments replies: [+] vzq@lemmy.blahaj.zone 1 point 2 years ago [deleted] permalink fedilink source parent [–] SpaceNoodle@lemmy.world 1 point 2 years ago Thanks! Agreed, it's a very limited usecase. permalink fedilink source parent [–] vzq@lemmy.blahaj.zone 1 point 2 years ago I have my doubts about the technique, but it could be useful in certain controlled situations This is completely uncontroversial advice and has been for 30 years. What are your doubts exactly? I’d go further: if you see a query that uses “offset” on a non-trivial production DB something is very, very wrong. Of course, the trick is that you need to make sure you have indexes for all sort orders you need to display, but that’s obvious. permalink fedilink source parent
[–] Max_P@lemmy.max-p.me 6 points 2 years ago Lemmy just implemented it for 0.19 and it makes a big difference on heavier queries like Scaled homepage. It also has the advantage of your pagination not getting screwy if new content has been added between page 2 and 3 queries. permalink fedilink source parent
[–] MegaMacSlice@programming.dev 3 points 2 years ago (1 child) I was going to recommend looking at https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#scroll-search-results - but it looks like that method is now not advised- but if you read up above it it looks like there’s a search_after/PIT method described which sounds similar to the article. This is all to say - I don’t think this is a one-off concept - it’s been around for a bit. permalink fedilink source parent hideshow 2 child comments replies: [+] vzq@lemmy.blahaj.zone 1 point 2 years ago [deleted] permalink fedilink source parent
[–] SpaceNoodle@lemmy.world 1 point 2 years ago Thanks! Agreed, it's a very limited usecase. permalink fedilink source parent
[–] vzq@lemmy.blahaj.zone 1 point 2 years ago I have my doubts about the technique, but it could be useful in certain controlled situations This is completely uncontroversial advice and has been for 30 years. What are your doubts exactly? I’d go further: if you see a query that uses “offset” on a non-trivial production DB something is very, very wrong. Of course, the trick is that you need to make sure you have indexes for all sort orders you need to display, but that’s obvious. permalink fedilink source parent
[–] starman@programming.dev [S] 1 point 2 years ago Sorry, I updated the link permalink fedilink source parent