skip/limit is pretty bad if you have a lot of rows. The database is actually iterating through all the items until it reaches the last item to skip. It's better to have some sort of index to use as a reference and fetch only the rows that have an index bigger than the reference index + limit
Totally agree with you. Especially, nowadays with db that charge per usage like PlanetScale where you are billed per row read and written. Going up with the items, you end up reading a 1000 rows to then return 100 (that's a weird way SQL works honestly). Personally, I am using a method that I read somewhere which is working pretty nicely. You keep the limit to decide the size of the page, and then you receive the last id and when you fetch you use that as a start so you never read more than the number of rows you actually need
@@JamesQQuickI think the introduction of these advanced concepts early on to people will help them understand how important it is. I know I had to learn the hard way from following simple examples that kept me in the dark. It is a very frustrating experience for people to go through.
The perfect explanation doesn't exi- but i thought that pagination is something where there are buttons 1, 2, 3 til the end and u click one of them and go to a page. never thought it was a single page thing too
It gives more flexibility to the frontend if the backend accepts both. Different apps may decide to display more/less items at a time. BUT using page number could definitely work!
For your Astro course, if you include how to deploy it to prod. Aka the web, I will buy it. I can get projects to run locally but as soon as it’s time to deploy I get lost.
@@JamesQQuick Your example would have the database iterating until the last row instead of utilizing an index. If you have a large database this is a bad idea.
@@jasonwelsh417 sshhh.. you are revealing too much arcane secret knowledge. I make jokes about how much of these things work great until the database grows or when encountering and dealing with large amounts of data.
skip/limit is pretty bad if you have a lot of rows. The database is actually iterating through all the items until it reaches the last item to skip. It's better to have some sort of index to use as a reference and fetch only the rows that have an index bigger than the reference index + limit
Totally agree with you. Especially, nowadays with db that charge per usage like PlanetScale where you are billed per row read and written. Going up with the items, you end up reading a 1000 rows to then return 100 (that's a weird way SQL works honestly). Personally, I am using a method that I read somewhere which is working pretty nicely. You keep the limit to decide the size of the page, and then you receive the last id and when you fetch you use that as a start so you never read more than the number of rows you actually need
Great point. It goes beyond the basics as covered in this video, but something worth calling out
@@JamesQQuickI think the introduction of these advanced concepts early on to people will help them understand how important it is. I know I had to learn the hard way from following simple examples that kept me in the dark. It is a very frustrating experience for people to go through.
The perfect explanation doesn't exi-
but i thought that pagination is something where there are buttons 1, 2, 3 til the end and u click one of them and go to a page. never thought it was a single page thing too
Pagination takes several different forms all with different use cases!
With was an awesome in a myriads of ways.
- Presentation
- clarity
- pace
- etc!
Thank you!
WOW! Thank you so much :)
Love it! I’ll be looking forward to learning more about Astro in September!🤘🤘
For the 1st kind of pagination that you mentioned, why not just pass the page number instead of the skip and calculate the skip server-side?
It gives more flexibility to the frontend if the backend accepts both. Different apps may decide to display more/less items at a time. BUT using page number could definitely work!
Always always always love your content James.
Great work
Thanks so much. really appreciate it :)
This was very interesting thanks
This was perfect. Thank you
So glad you enjoyed it!
This is really nice man
So glad you think so@
Amazing. Do you have a tutorial for a blog with React and Firebase (or other DB)?
what is the vs code theme you are using?? please mention
Which VS Code theme are you using?
This is my own theme - James Q Quick :)
That's Cool 🔥🔥🔥@@JamesQQuick
How about cursorbased 0:44 pagination? And 'infinitive' data like dates.
but what if the url not have limit and skip query
For your Astro course, if you include how to deploy it to prod. Aka the web, I will buy it.
I can get projects to run locally but as soon as it’s time to deploy I get lost.
Definitely will include publishing to prod!
c'est pas plus facile getjson => create tab => read 10 first elements ?
James, how much money Astro pays for your ad?
None at all :) Thanks for clarifying that!
thanks >
You can tell this guy has never worked on a production database before
Lol why is that?
@@JamesQQuick Your example would have the database iterating until the last row instead of utilizing an index. If you have a large database this is a bad idea.
@@jasonwelsh417 sshhh.. you are revealing too much arcane secret knowledge. I make jokes about how much of these things work great until the database grows or when encountering and dealing with large amounts of data.