This happened to me the other week, and my colleag...
# suitescript
d
This happened to me the other week, and my colleague today: Sometimes for very large searches in a map reduce script, it could take the
getInput()
phase up to 12 hours to complete. But running the same saved search in the UI, or in code returns very quickly. Does anyone know what's up with that?
s
This could also be due to getInputData() needing to load ALL the search results, whereas in the UI it needs to only render one very short page of results.
d
that makes sense, in the docs somewhere they state that you should return a search reference:
return { type: "search", id: "my_search_id"}
, and supposedly they would optimize the search on the back end, but that's apparently not always the case 😛
s
is that how you're using
getData()
now (i.e. returning an object that tells it what search to run?)
Logically, it seems operations like
reduce
MUST wait until ALL results have been processed else it can't know what groupings should emit to the reduce stage until candidate has already flowed through the map stages
d
yes, i've been using a pattern like:
Copy code
function getInputData(ctx){
  return{
    type: "search",
    id: runtime.getParameter('my_search_param')
  }
}
But yes, like you've said, I think it does have to wait until the entire search result is completed before it passes off to the next state. And it is still limited to return 200MB of data to
map()
recently I had a task to delete 30 million custom log records, and this pattern was falling flat on it's face. So instead I had it run a search that only returned:
Min(internalid)
and
Max(internalid)
, just one search result with two fields, then had my
map()
use
context.write()
to spin out block of id's to delete