Queries Module

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

    Returns the servers current query tracking configuration; we change the slow query threshold to get better results:

    Show execution results

    1. {
    2. "code" : 200,
    3. "enabled" : true,
    4. "trackSlowQueries" : true,
    5. "trackBindVars" : true,
    6. "maxSlowQueries" : 64,
    7. "slowQueryThreshold" : 10,
    8. "maxQueryStringLength" : 4096
    9. {
    10. "code" : 200,
    11. "enabled" : true,
    12. "trackSlowQueries" : true,
    13. "trackBindVars" : true,
    14. "maxSlowQueries" : 64,
    15. "slowQueryThreshold" : 1,
    16. "maxQueryStringLength" : 4096
    17. }

    Hide execution results

    We create a task that spawns queries, so we have nice output. Since this taskuses resources, you may want to increase (and not forget to remove it… afterwards):

    1. arangosh> var theQuery = 'FOR sleepLoooong IN 1..5 LET sleepLoooonger = SLEEP(1000) RETURN sleepLoooong';
    2. arangosh> var tasks = require("@arangodb/tasks");
    3. arangosh> tasks.register({
    4. ........> id: "mytask-1",
    5. ........> command: "require('@arangodb').db._query('" + theQuery + "');"
    6. ........> });
    7. arangosh> queries.current();

    Hide execution results

    The function returns the currently running AQL queries as an array.

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

    1. arangosh> queries.slow();

    Show execution results

    1. [ ]

    Hide execution results

    Show execution results

    1. {
    2. "code" : 200
    3. }
    4. [ ]

    Hide execution results

    Kill a running AQL query:

    1. arangosh> var runningQueries = queries.current().filter(function(query) {
    2. ........> return query.query === theQuery;
    3. ........> });
    4. arangosh> queries.kill(runningQueries[0].id);

    Show execution results

    Hide execution results