0

I have ArangoDB query. This query executes generally normal, but suddenly too long

WITH
DependantPerson, PersonServiceProfile, MonitoringRule, DeviceSensor, PersonDevice, Subscription, Person, Link, DeviceApplication, Contact
FOR res IN @resource_from
LET sub = (FOR e, v, p IN @min_depth..@max_depth INBOUND res  Link FILTER (p.vertices[*].type ANY == "DeviceSensor") RETURN p)
RETURN {
  [res]:sub[*
    RETURN {
      relations: CURRENT.edges[* FILTER (CURRENT.type != "Link" && CURRENT.type != "ObserveLink") RETURN CURRENT ],
      resources: CURRENT.vertices[* FILTER (CURRENT.type == "DeviceSensor" && CURRENT.attributes.deviceId == @id) RETURN CURRENT ]
      }
    ] 
}

Cache is turned off

require("@arangodb/aql/cache").properties()
{
  "mode" : "off",
  "maxResults" : 128
}

How can i optimize this? Thanks

  • What does _too long_ mean, a full minute but normally below a second? Are the bind parameters the same each time? What do you set `@min_depth` and `@max_depth` to? And how does your graph look, as in how many edges need to be followed to fulfill the request (rough estimate)? – CodeManX Nov 22 '18 at 19:42
  • @CoDEmanX, Too Long is about 30 sec. Normally it executes for milliseconds. @min_depth=@max_depth=2. All parameters are the same each time. Edges is only Link collection. Person node has 7 edges with others nodes. – Антон Козлов Nov 27 '18 at 12:43
  • What's the exact ArangoDB version and which storage engine is in use? Are there any concurrent queries or imports, e.g. writes that might block any of the collections that are involved in the traversal? Is there anything notable in regards to the system resources in the moment the query takes much longer than usual, e.g. swapping? – CodeManX Nov 28 '18 at 22:06
  • @CoDEmanX, Version ArangoDB is 3.3.17. Storage engine is RocksDB. ReplicationFactor is 4 and NumberOfShards is 1 for all collections. System resources don't have unusual load in the moment the query – Антон Козлов Nov 29 '18 at 06:31
  • Do you see similar behavior with non-graph queries as well? Or any network latency spikes in general? Can you try with replication factor 1? If everything runs on one node locally and it still takes 30s sometimes, then it would be related to the query or storage engine I guess, otherwise it could be be problem with the cluster or network. – CodeManX Dec 03 '18 at 12:08

0 Answers0