Queries Module

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

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

    Show execution results

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

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

    1. arangosh> tasks.register({
    2. ........> id: "mytask-1",
    3. ........> name: "this is a sample task to spawn a slow aql query",
    4. ........> command: "require('@arangodb').db._query('" + theQuery + "');"
    5. ........> });
    6. 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

    Hide execution results

    1. [ ]

    Show execution results

    Hide execution results

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

    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