简体   繁体   English

ArangoDB 2.8-按子查询结果排序-失败

[英]ArangoDB 2.8 - sort by subquery result - failure

After move to 2.8 this simple query now froze server with 100% CPU usage ~10sec. 移至2.8后,此简单查询现在冻结了100%CPU使用率〜10秒的服务器。 In 2.7 (~30ms) 在2.7(〜30ms)

FOR P In Person
   LET EventLast = (
    FOR E In Event FILTER E.owner == P._id SORT E.date desc LIMIT 1 RETURN E.date
   )
SORT EventLast[0]
LIMIT 40
RETURN { _id: P._id, name:P.name }

Collection Event have skiplist index in date and hash index on owner 收集事件在date具有跳过列表索引,在owner上具有哈希索引

Without "SORT E.date desc" or "SORT EventLast[0]" - 1ms 没有“ SORT E.date desc”或“ SORT EventLast [0]”时-1ms

The query optimizer in 2.8-beta picked the skiplist index on date for the inner subquery. 2.8-beta中的查询优化器在date为内部子查询选择了跳过列表索引。 This index allows removing the SORT clause, but the inner query still needs to scan the entire index in reverse order until the first filter match. 该索引允许删除SORT子句,但是内部查询仍然需要以相反的顺序扫描整个索引,直到第一个过滤器匹配为止。 It does that as many times as there are documents in Person . 这样做的次数与Person中的文档次数相同。

The 2.7 optimizer instead picked the hash index on owner and used a post-index- SORT . 2.7优化程序改为选择owner的哈希索引,并使用post-index- SORT This was probably better in this case if the number of matches per index lookup is very small, but will be bad if the filter is very unselective. 在这种情况下,如果每个索引查找的匹配数很小,这可能会更好,但是如果过滤器的选择性很差,那就不好了。

The 2.8 optimizer will now again prefer the potentially more selective hash index for the inner query. 现在,2.8优化器将再次为内部查询选择可能更具选择性的哈希索引。 A fix for this has been made today in the 2.8 branch, which will turn into a beta3 or rc (note that there will be a beta2 soon that won't yet contain the fix). 今天已在2.8分支中对此问题进行了修复,它将变为beta3或rc(请注意,不久将有一个beta2尚不包含此修复程序)。

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

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