Hi Everyone, I am facing a performance issue with ...
# suitescript
v
Hi Everyone, I am facing a performance issue with a Suitelet where I am loading three saved searches, combining the results, and displaying them on the Suitelet page; the combined results are more than 50,000 records, and although I am using pagination with 1,000 records per page, the Suitelet URL takes too long to load initially and navigating between pages is also very slow, so I would like to know what is the best way in NetSuite to efficiently handle such a large volume of records with minimum load time, and later I also need to add an “Export to Excel” functionality for these results.
g
My first thought is don't try to display 50k records. What is the use case for displaying that many records. Pull back what you are displaying in the UI and leave the 50k records for the CSV export if someone really needs that. When you say it takes to long, what takes to long, are the searches themselves taking to long, the combining of results? You could just have a super inefficient saved search that is taking forever. Do you need 3 searches or can it be combined into one? SuiteQL?
☝️ 1
a
pagination buys you efficiency by not getting all the results... if you're doing 3 searches and combining the results by definition you're doing all 3 searches in full, paginating the display of the results won't speed things up significantly I wouldn't think
to leverage pagination you might consider combining into a single query instead of 3 searches, the query module allows you to join much more broadly then a saved search
a
If you can't get everything using a query then use promises so you run those 3 searches in parallel then group the results and reduce the amount of results you show on the UI, use pagination not only on the searches but for the result. For example only show the first 1000 results, if the user click next page then you perform another search for the next 1000 results.
c
50k+ records will overwhelm a Suitelet no matter how you paginate it. The best approach is to handle the heavy lifting in Map/Reduce, store the results in a custom table, and then load and paginate from there. For Excel export, build from the stored results instead of re-querying searches each time.
a
You can 100% show 1 million results or any amount of results with a Suitelet when proper pagination is implemented. You could also use third party libraries like: • DataTables • AG-Grid No Map Reduce needed at all...
s
I have to agree with @alien4u and disagree with @christianRILECPQ
though with a requirement like that, I'd just be building a lightweight Angular app rather than vanilla Suitelet.