I have an simple query runs inside foxx
For u in collection
Filter u.someIndexedSparseFiler !=null
Return {_id:u._id}
This will return millions+ results. In the logs, arango have a message of limited memory heap reached and terminate the process.
reached heap-size limit of #3 interrupting V8 execution (heap size limit 3232954528, used 3060226424) during V8 internal collection
Even though I add the flag --javascript.v8-max-heap 3000 to the start-up. It still runs in the same error. What should I do? Is there a better approach than this
I'm not sure why you're getting out-of-memory errors, but it looks like the data you're returning is overflowing the V8 heap size. Another possibility is that something is causing the engine to miss/ignore the index, causing the engine to load every document before evaluating the
someIndexedSparseFilerattribute.Evaluating millions of documents (or lots of large documents) would not only cost a lot of disk/memory I/O, but could also require a lot of RAM. Try using the explain feature to return a query analysis - it should tell you what is going wrong.
For comparison, my query...
...returns this when I click "explain":
Note that it listss my sparse index under
Indexes used:. Also, try changing the!=to==and you will see that now it ignores the index! This is because the optimizer knows a sparse index will never have anullvalue, so it skips it.If you aren't familiar with it, the "explain" functionality is extremely useful (indispensable, really) when tuning queries and creating indexes. Also, remember that indexes should match your query; in this case, the index should only have one attribute or the "selectivity" quotient may be too low and the engine will ignore it.