I'm designing a DB with ArangoDB for a Web Application. I wrote the following AQL query:
FOR result
IN Collection
FILTER result.field != 'undefined'
RETURN result
I added some type of index for field but query doesn't use any indexes in no way.
In your opinion what is the problem? I read that for == operator we can use hash index and for <= or similar operators skip list.
Now, what is the correct way to do the same thing?
!=
operator is used on an attribute, no index will be used. First of all, the hash indexes don't support this type of operation. For skiplists, the operation could theoretically be transformed intoresult.field < 'undefined' OR result.field > 'undefined'
, so two disjoint ranges could in theory be queried from such index. But in general, the point of using an index is to filter out as many documents as early as possible in the query, and in many cases the!=
will not lead to a big reduction. – stj