J@ArangoDB

{ "subject" : "ArangoDB", "tags": [ "multi-model", "nosql", "database" ] }

Small Things in 2.8: Explain Improvements

Explaining AQL queries becomes even easier in ArangoDB 2.8.

While previous versions required writing a hard-to-memoize command like

explaining a query in 2.7
1
require("org/arangodb/aql/explainer").explain(query);

to explain an AQL query from the ArangoShell, 2.8 reduces this task to a mere

explaining a query in 2.8
1
db._explain(query);

Apart from that, explain in 2.8 is smarter when confronted with very lengthy query strings, and with queries that contain huge hard-coded string, array, or object values.

For example, when creating an array bind variable with 1,000 values and using them in an explained query, 2.7 would print the entire 1,000 array values in the explain output:

explaining a query with 1000 array values
1
2
3
4
5
6
7
8
9
10
11
12
var keys = [];
for (var i = 0; i < 1000; ++i) {
  keys.push("test" + i);
}

var query = "FOR i IN @keys RETURN i";
require("org/arangodb/aql/explainer").explain({
  query: query,
  bindVars: {
    keys: keys
  }
});

2.8 will instead truncate longer arrays and objects in the explain output for much improved readability:

Automatic value truncation will occur for array and object values with more than 20 elements or for string values longer than 1,024 characters. The truncation for explain will occur if these values are hard-coded into the query or are passed via bind parameters.

Truncation only happens inside the explain results processing and thus cannot affect the actual query results.