This content originally appeared on DEV Community and was authored by The Nerdy Dev
Hey everyone,
In this article, let us discuss about a very important question regarding filtering the data that we get from the database or API. So the question is :Â
Where exactly should we filter the data ?Â
ð€ Backend ... ?Â
ð€ Frontend ... ?Â
Well, the answer is :Â
It depends.Â
Let us discuss now :Â
So if you have a a large amount of data, it is better to implement the filtering logic on the backend and let the database handle all the heavy lifting for us. Contrary to this, if you are dealing with less amount of data, you can do the filtering logic on the frontend.
In general, if you are working with a million recordset (as an example) and there are tons of users trying to access those records at the very same, then in such cases it does not make sense to send a million recordset to every user who is currently accessing the website. It simply does not make sense because it will simply bring your website down, so what we do in such cases is that we setup a record limit (kind of we send the data in batches) by using a features like database cursors. So kind of with the cursors in place, you can fetch the data in batches in some sort of pagination etc. Consider a big ecommerce website like Amazon, this is how they handle that amount of data in a nutshell.
For less amount of data, you could retrieve the data from the backend and then use the filtering logic on the frontend.
So this is it for this article. Thanks for reading.
Don't forget to leave a like if you loved the article. Also share it with your friends and colleagues.
PS - If you are looking to learn Web Development, I have curated a FREE course for you on my YouTube Channel, check the below article :
(2021) - Web Developer Full Course : HTML, CSS, JavaScript, Node.js and MongoDB
The Nerdy Dev ã» Apr 28 ã» 2 min read
Looking to learn React.js with one Full Project, check this out :
Learn React with one BIG Project [NOTES included] - Demo and Video Link
The Nerdy Dev ã» Jun 10 ã» 1 min read
This content originally appeared on DEV Community and was authored by The Nerdy Dev
The Nerdy Dev | Sciencx (2021-11-10T06:11:46+00:00) ð€Where to filter the data – backend or frontend ?. Retrieved from https://www.scien.cx/2021/11/10/%f0%9f%a4%94where-to-filter-the-data-backend-or-frontend/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.