title: ArangoDB. Long time query
body: <p>I have ArangoDB query. This query executes generally normal, but suddenly too long</p>
  
  <pre><code>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" &amp;&amp; CURRENT.type != "ObserveLink") RETURN CURRENT ],
        resources: CURRENT.vertices[* FILTER (CURRENT.type == "DeviceSensor" &amp;&amp; CURRENT.attributes.deviceId == @id) RETURN CURRENT ]
        }
      ] 
  }
  </code></pre>
  
  <p>Cache is turned off</p>
  
  <pre><code>require("@arangodb/aql/cache").properties()
  {
    "mode" : "off",
    "maxResults" : 128
  }
  </code></pre>
  
  <p>How can i optimize this? Thanks</p>