From dfafae42b881de4b3c3345e679e013417d8609d2 Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 21 Aug 2019 18:09:37 +0200 Subject: [PATCH] show query string length and cacheability in explain output (#9768) --- CHANGELOG | 2 ++ js/common/modules/@arangodb/aql/explainer.js | 15 ++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index cdc31e08ab..f807b38326 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ v3.5.1 (XXXX-XX-XX) ------------------- +* Show query string length and cacheability information in query explain output. + * The AQL functions `FULLTEXT`, `NEAR`, `WITHIN` and `WITHIN_RECTANGLE` are now marked as cacheable, so they can be used in conjunction with the AQL query results cache on a single server. diff --git a/js/common/modules/@arangodb/aql/explainer.js b/js/common/modules/@arangodb/aql/explainer.js index cc0f23e1a2..92b0fcc57f 100644 --- a/js/common/modules/@arangodb/aql/explainer.js +++ b/js/common/modules/@arangodb/aql/explainer.js @@ -162,17 +162,18 @@ function pad(n) { /* print functions */ /* print query string */ -function printQuery(query) { +function printQuery(query, cacheable) { 'use strict'; // restrict max length of printed query to avoid endless printing for // very long query strings - var maxLength = 4096; + var maxLength = 4096, headline = 'Query String (' + query.length + ' chars'; if (query.length > maxLength) { - stringBuilder.appendLine(section('Query String (truncated):')); + headline += ' - truncated...'; query = query.substr(0, maxLength / 2) + ' ... ' + query.substr(query.length - maxLength / 2); - } else { - stringBuilder.appendLine(section('Query String:')); } + headline += ', cacheable: ' + (cacheable ? 'true' : 'false'); + headline += '):'; + stringBuilder.appendLine(section(headline)); stringBuilder.appendLine(' ' + value(stringBuilder.wrap(query, 100))); stringBuilder.appendLine(); } @@ -700,7 +701,7 @@ function processQuery(query, explain, planIndex) { if (planIndex !== undefined) { plan = explain.plans[planIndex]; } - + /// mode with actual runtime stats per node let profileMode = stats && stats.hasOwnProperty('nodes'); @@ -1718,7 +1719,7 @@ function processQuery(query, explain, planIndex) { }; if (planIndex === undefined) { - printQuery(query); + printQuery(query, explain.cacheable); } stringBuilder.appendLine(section('Execution plan:'));