Reputation: 1553
For example, I have this data structure
{
easyFilter:1111,
hardFilter:[
{id:1},
{id:2},
...
]
}
If the query I use is like
For u in collection
Filter u.easyFilter=1111 AND "somevalue" IN FLATTEN(u.hardFilter[*].id)
return u
Will the query run faster if I place easyFilter
first since it just string comparison on the first level of a object or it does not matter in arango?
Upvotes: 1
Views: 315
Reputation: 514
Yes, order of FILTER statements does affect performance of query.
Especially in your case, where
easyFilter
is just string comparison,
while hardFilter
is constructed from multiple operations
What's omitted is the importance of indexes. They are THE one behind truly performat queries. Check Handling Indexes in ArangoDB documentation, especially Which Index to use when.
For improving performance of your example would be definitely helpful to add Hash or Skiplist index easyFilter (depends on type / uniqueness of your data). Both indexes support also arrays, but based on documentation, that applies only to simple arrays containing values, not objects.
Upvotes: 2