Arango logo

ArangoDB v4.x is under development and not released yet.

This documentation is not final and potentially incomplete.

The @arangodb/aql/queries module of the JavaScript API

The query module provides the infrastructure for working with currently running AQL queries via arangosh

const queries = require('@arangodb/aql/queries')

Properties

queries.properties() Returns the servers current query tracking configuration; we change the slow query threshold to get better results:

var queries = require("@arangodb/aql/queries");
queries.properties();
queries.properties({slowQueryThreshold: 1});
queries.properties({slowStreamingQueryThreshold: 1});
Show output
{ 
  "code" : 200, 
  "enabled" : true, 
  "trackSlowQueries" : true, 
  "trackBindVars" : true, 
  "maxSlowQueries" : 64, 
  "slowQueryThreshold" : 10, 
  "slowStreamingQueryThreshold" : 10, 
  "maxQueryStringLength" : 4096 
}

{ 
  "code" : 200, 
  "enabled" : true, 
  "trackSlowQueries" : true, 
  "trackBindVars" : true, 
  "maxSlowQueries" : 64, 
  "slowQueryThreshold" : 1, 
  "slowStreamingQueryThreshold" : 10, 
  "maxQueryStringLength" : 4096 
}

{ 
  "code" : 200, 
  "enabled" : true, 
  "trackSlowQueries" : true, 
  "trackBindVars" : true, 
  "maxSlowQueries" : 64, 
  "slowQueryThreshold" : 1, 
  "slowStreamingQueryThreshold" : 1, 
  "maxQueryStringLength" : 4096 
}

Currently running queries

The example code starts a query in a non-blocking fashion before calling queries.current() so that it returns something.

var theQuery = "FOR sleepLong IN 1..5 LET sleepLonger = SLEEP(1) RETURN sleepLong";
arango.POST("/_api/cursor", {query: theQuery}, {"X-Arango-Async":true});
queries.current();
Show output
{ 
  "code" : 202, 
  "error" : false 
}
[ 
  { 
    "id" : "75468", 
    "database" : "_system", 
    "user" : "root", 
    "query" : "FOR sleepLong IN 1..5 LET sleepLonger = SLEEP(1) RETURN sleepLong", 
    "bindVars" : { 
    }, 
    "started" : "2026-04-24T21:48:54Z", 
    "runTime" : 0.0011005870000531104, 
    "peakMemoryUsage" : 32768, 
    "state" : "executing", 
    "stream" : false, 
    "modificationQuery" : false, 
    "warnings" : 0 
  } 
]

Slow queries

The function returns the last AQL queries that exceeded the slow query threshold as an array:

queries.slow();
Show output
[ ]

Clear slow queries

Clear the list of slow AQL queries:

queries.clearSlow();
queries.slow();
Show output
{ 
  "code" : 200 
}

[ ]

Kill

Kill a running AQL query:

var runningQueries = queries.current().filter(q => q.query === theQuery);
queries.kill(runningQueries[0].id);
Show output
{ 
  "code" : 200 
}