简体   繁体   English

ArangoDB慢速查询

[英]ArangoDB Slow Query

I'm new to ArangoDB, having trouble optimizing my queries and am hoping for some help. 我是ArangoDB的新手,无法优化我的查询,希望得到一些帮助。

The query I've provided below is a real example that I'm struggling with, 758.078 ms on my dev database but on staging, with a much larger dataset, it takes 531.511 s . 我在下面提供的查询是一个真正的例子,我正在努力,在我的开发数据库上758.078毫秒 ,但在登台时,有一个更大的数据集,它需要531.511秒

I'll also provide the size of each of the edge tables I'm traversing in dev and staging. 我还将提供我在dev和staging中遍历的每个边表的大小。 Any help is really appreciated. 任何帮助都非常感谢。

for doc in document
filter repo._key == "my-key"
    for v, e, p in 3 any doc edge1, edge2, edge3
    options {uniqueVertices: 'global', bfs: true}
    filter DATE_ISO8601(p.vertices[2].date) > DATE_ISO8601("2017-09-04T00:00:01Z")
        and DATE_ISO8601(p.vertices[2].date) < DATE_ISO8601("2017-09-15T23:59:59Z")
    limit 1
    return {
        commit: p.vertices[2].hash,
        date: p.vertices[2].date,
        message: p.vertices[2].message,
        author: p.vertices[1].email,
        loc: p.vertices[3].stats.additions
    }

DEV DEV

  • edge1: 2,638 edge1:2,638
  • edge2: 2,560 edge2:2,560
  • edge3: 386 edge3:386

STAGING 分期

  • edge1: 5,438,811 edge1:5,438,811
  • edge2: 5,544,028 edge2:5,544,028
  • edge3: 423,545 edge3:423,545

The query is potentially slow because the filter condition 由于过滤条件,查询可能很慢

filter 
  DATE_ISO8601(p.vertices[2].date) > DATE_ISO8601("2017-09-04T00:00:01Z"
and 
  DATE_ISO8601(p.vertices[2].date) < DATE_ISO8601("2017-09-15T23:59:59Z")

is not applied during the traversal but only afterwards. 在遍历期间不应用,但仅在之后应用。 Potentially this is due to the function calls (to DATE_ISO8601 ) in the filter conditions. 这可能是由于过滤条件中的函数调用(到DATE_ISO8601 )。 If your date values are stored as numbers, can you check whether the following filter condition speeds up the query: 如果您的日期值存储为数字,您可以检查以下过滤条件是否加快查询速度:

filter 
  p.vertices[2].date > DATE_TIMESTAMP("2017-09-04T00:00:01Z"
and 
  p.vertices[2].date < DATE_TIMESTAMP("2017-09-15T23:59:59Z")

That modified filter condition should allow pulling the filter condition inside the traversal, so it is executed earlier. 修改过滤条件应该允许在遍历内拉过滤条件,因此它会更早执行。

You can verify the query execution plans using db._explain(<query string goes here>); 您可以使用db._explain(<query string goes here>);验证查询执行计划db._explain(<query string goes here>); in the ArangoShell or from the web interface's AQL editor. 在ArangoShell中或从Web界面的AQL编辑器中。

Probably a bit late but it will help someone. 可能有点晚了,但它会帮助别人。 Using the DATE function will make the query much slower, so if possible remove the DATE function. 使用DATE函数会使查询更慢,因此如果可能,请删除DATE函数。 For example enter image description here 例如,在此处输入图像描述 在此输入图像描述

You can see that the query filter command uses a Date function that is ~ 7s. 您可以看到查询过滤器命令使用~7s的Date函数。 If you do not use the date function, it will run faster than ~ 0.5s. 如果不使用日期函数,它将比~0.5秒运行得更快。 These two lines will query the data of 2018-09-29. 这两行将查询2018-09-29的数据。

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

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