简体   繁体   English

FILTER语句的顺序是否会影响arangoDB中的查询性能?

[英]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? 如果我将easyFilter放在第一位,因为它只是在对象的第一级上进行字符串比较,那么查询运行速度会更快吗?

Yes, order of FILTER statements does affect performance of query. 是的,FILTER语句的顺序确实会影响查询的性能。

Especially in your case, where 特别是在您的情况下

easyFilter is just string comparison, easyFilter只是字符串比较,

while hardFilter is constructed from multiple operations hardFilter是由多个操作构成的

  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 . 检查ArangoDB文档中的 处理索引 ,特别是何时使用哪个索引

For improving performance of your example would be definitely helpful to add Hash or Skiplist index easyFilter (depends on type / uniqueness of your data). 为了提高示例的性能,添加哈希Skiplist索引easyFilter绝对有帮助(取决于数据的类型/唯一性)。 Both indexes support also arrays, but based on documentation, that applies only to simple arrays containing values, not objects. 这两个索引也都支持数组,但是基于文档,这仅适用于包含值的简单数组,而不适用于对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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