InfiniteQuery or Pagination

how to implement it with the Drizzle orm, is there some example, how to use cursor?
1 Reply
mrnicericee
mrnicericee•17mo ago
Hey luka! with drizzle you have to write the query closer to sql. the infinite query is weirdly placed in the title because it's mostly a frontend abstraction of the backend pagination. so, it sounds like you want to learn more about different ways to paginate data in the backend! since it would be terrible to receive thousands of rows of data! the one that will be the easiest to implement is limit + offset. pros: able to do pages, and you can do "page 1" and go to "page 200" very easily. cons: say you are paginating 25 at a time, and you want to query row 1 million, the select has to iterate 1 million times + fetch your 25. the one i typically use is key set. you have a column & id you agree on that you will do a WHERE statement on pros: fetching the million + 25, now is a lot faster because it skipped all of the first million, and goes for the 25. cons: can't do "page 1" to page "200", since you need the cursor/key set id what i mentioned just now is described in great detail by slack. i recommend giving it a read, and then looking up how to do both limit + offset and key set paginations. you're most likely be fine with just a limit + offset solution 🙂 https://slack.engineering/evolving-api-pagination-at-slack/
Slack Engineering
Slack Engineering
Evolving API Pagination at Slack - Slack Engineering
At Slack, the size and scope of the data we expose via our APIs has changed dramatically since the product first launched. Endpoints that were designed around the expectation that they would, in the most extreme cases, return several hundred records, are now returning hundreds of thousands of records. To handle this rapid growth, we’ve …
Want results from more Discord servers?
Add your server