Bibudha R Sahoo Bibudha R Sahoo - 1 month ago 9
React JSX Question

How to handle millions of records in react js and sails js

I have a table having millions of records. I am using Sails js as my server side code , React js to render data in view and Mysql as my DBMS. So what is the best method to retrieve the data in faster manner.

Like the end user does not feel like getting a huge amount of data which affects UI as well.

Shall I bring only 50 records first and show the pagination in bottom using pagination logic and then using socket.io fetch the rest in background ?

Or any good way of handling it ?

Answer

This really depends on how you expect your user to go through the data. You will probably want an API call for getting only the first page of data (likely in such a way that you can fetch any page: api/mydata/<pagesize>/<pagenumber>).

Then it depends on wha tyou expect your user to do. Is he going to click through every page to see all the data? In that case it seems ok to load all the other aswell as you mentioned. This seems unlikely to me however.

If you expect your user to only view a few pages, you could load the data for the next page in the background (api/mydata/<pagesize>/<currentpage+1>), and then load the next page everytime the user navigates.

Then you probably still need to support jumping to certain page number, where you will need to check if you have the data or not, and then show a loading state (or nothing) while the data is being fetched.

All this said, I don't see why you would need socket.io instead of normal requests (you really only need socket.io if the server needs to be abled to make 'requests' to the client so to speak)

Comments