为什么这个简单的ArangoDB查询有时需要很长时间

时间:2016-09-27 09:07:07

标签: performance arangodb

我通过arangojs.query()使用这个非常简单的查询查询ArangoDb大约500k文档

"FOR c IN Entity FILTER c.id == 261764 RETURN c"

它是节点链接图中的节点。

但有时候,花了10多秒钟,在arangodb的日志中也有关于查询耗时太长的警告。如果在浏览器上使用新会话,会发生很多时间。是arangodb或arangojs的问题还是我的查询本身没有优化?

-------------------编辑----------------------

添加了db.explain

Query string:
 FOR c IN Entity FILTER c.id == 211764 RETURN c

Execution plan:
 Id   NodeType                    Est.   Comment
  1   SingletonNode                  1   * ROOT
  2   EnumerateCollectionNode   140270     - FOR c IN Entity   /* full collection scan */
  3   CalculationNode           140270       - LET #1 = (c.`id` == 211764)   /* simple expression */   /* collections used: c : Entity */
  4   FilterNode                140270       - FILTER #1
  5   ReturnNode                140270       - RETURN c

使用的索引:

 none

应用优化规则:

 none

1 个答案:

答案 0 :(得分:2)

正如您的说明所示,您的查询并未使用索引,但会进行完整的收集扫描。

取决于何时找到匹配(在集合的开头或结尾),执行时间可能会有所不同。

请参阅the Indexing chapter创建索引,AQL Execution and Performance章节如何分析#The dataset must be created before it can be used in the script: $dataSet = New-Object System.Data.DataSet #MYSQL query $command = $myconnection.CreateCommand() $command.CommandText = " SELECT ID, Date_Close, Time_Close FROM systemcontrol.database_close WHERE Date_Close >= CONCAT(YEAR(NOW()), '-', MONTH(NOW()), '-01') AND Database_Close_ID = 1 ORDER BY Date_Close DESC "; Write-Host "4B - Sales Reports Month End Database" $reader = $command.ExecuteReader() #The data reader will now contain the results from the database query. $result = @() #Processing the Contents of a Data Reader #The contents of a data reader is processes row by row: while ($reader.Read()) { #And then field by field: for ($i= 0; $i -lt $reader.FieldCount; $i++) { $value = $reader.GetValue($i).ToString() Write-Output $value $result += $value } } ConvertTo-Html -Body $result -Title "4B - Sales Reports Month End Database" | Out-File C:\************.HTML Send-MailMessage -From " Daily Check <server@company.com>" -To "Admin <admin@admin>" -Subject "Daily Check: Server Times" -Body "$reader" -Priority High -Dno onSuccess, onFailure -SmtpServer 1.xx.xx.xx $myconnection.Close() 的输出