Search code examples
arangodb

How do I get elapsed time in the rest interface with ArangoDB?


How do I get elapsed query time in the REST interface with ArangoDB? (an additional json field with the elapsed time)

Thanks.


Solution

  • Its possible to get profile information for the different execution phases of AQL queries via setting the profile option to true.

    It can be done in arangosh like this:

    q = "FOR doc IN _users RETURN doc";
    s = db._createStatement({ query: q, options: { profile: true } });
    res = s.execute().getExtra();
    

    The resulting json of the getExtra() will look like that:

    {
      "stats" : { 
        "writesExecuted" : 0, 
        "writesIgnored" : 0, 
        "scannedFull" : 1, 
        "scannedIndex" : 0, 
        "filtered" : 0 
      }, 
      "profile" : { 
        "initializing" : 0.0000040531158447265625, 
        "parsing" : 0.00003600120544433594, 
        "optimizing ast" : 0.0000040531158447265625, 
        "instantiating plan" : 0.000010967254638671875, 
        "optimizing plan" : 0.000023126602172851562, 
        "executing" : 0.00004601478576660156 
      }, 
      "warnings" : [ ] 
    }