Today I learned that running a big saved search in...
# suitescript
w
Today I learned that running a big saved search in 1.0 using search.runSearch() + searchResults.getResults() is waaay less efficient than using 2.0's search.runPaged() + pagedData.fetch. It seems like 1.0 runs the complete search each time you call searchResult.getResults(start,delta). 2.0 only runs the complete search on search.runPaged() and then each call to pagedData.fetch() is very fast. The test below has been executed in the console.
🙌 1
👍 1
p
Pretty extreme difference
Would be fun do the same search via runSuiteQL as well
👍 1
w
I read up on search.runPaged. Note that it only supports 1000 pages, so a maximum of 1 million rows. The search that I executed in the example returns 2,2 million rows. That would potentially explain why the search is twice as fast compared to a single getResults in ss1.0. The documentation also states that the search is not cached in 2.0, so I suspect it is running the search and extract some start and end-row in some way for each page before it returns the pagedData-object.