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. "slowStreamingQueryThreshold" : 10,
    9. "maxQueryStringLength" : 4096
    10. }
    11. {
    12. "code" : 200,
    13. "trackSlowQueries" : true,
    14. "trackBindVars" : true,
    15. "maxSlowQueries" : 64,
    16. "slowQueryThreshold" : 1,
    17. "slowStreamingQueryThreshold" : 10,
    18. "maxQueryStringLength" : 4096
    19. }
    20. {
    21. "code" : 200,
    22. "enabled" : true,
    23. "trackSlowQueries" : true,
    24. "trackBindVars" : true,
    25. "maxSlowQueries" : 64,
    26. "slowQueryThreshold" : 1,
    27. "slowStreamingQueryThreshold" : 1,
    28. "maxQueryStringLength" : 4096
    29. }

    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 tasks = require("@arangodb/tasks");
    2. arangosh> tasks.register({
    3. ........> id: "mytask-1",
    4. ........> name: "this is a sample task to spawn a slow aql query",
    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