简体   繁体   中英

Does the order of FILTER statement affect the performance of query in arangoDB?

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?

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

  1. iterating array + getting values of defined key
  2. flattening that array
  3. checking if array contains defined value

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM