pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Fetter <david@fetter.org>
To: PostgreSQL Development <pgsql-hackers@postgresql.org>
Subject: Re: New EXPLAIN option: ALL
Date: Tue, 7 May 2019 09:50:47 +0200
Message-ID: <20190507075047.GJ28936@fetter.org> (raw)
In-Reply-To: <20190507073046.GI28936@fetter.org>
References: <20190507073046.GI28936@fetter.org>

On Tue, May 07, 2019 at 09:30:47AM +0200, David Fetter wrote:
> Folks,
> 
> It can get a little tedious turning on (or off) all the boolean
> options to EXPLAIN, so please find attached a shortcut.
> 
> Best,
> David.

It helps to have a working patch for this.

Best,
David.
-- 
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

Attachments:

v2-0001-Add-an-ALL-option-to-EXPLAIN.patch (text/x-diff, 4.3K) download From d62669c5b1d22c18949ad5d6ae3f6b23b49819e3 Mon Sep 17 00:00:00 2001 From: David Fetter <david@fetter.org> Date: Tue, 7 May 2019 00:26:29 -0700 Subject: [PATCH v2] Add an ALL option to EXPLAIN To: hackers MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.21.0" This is a multi-part message in MIME format. --------------2.21.0 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit which starts all boolean options at once. diff --git a/doc/src/sgml/ref/explain.sgml b/doc/src/sgml/ref/explain.sgml index 385d10411f..ade3793c5f 100644 --- a/doc/src/sgml/ref/explain.sgml +++ b/doc/src/sgml/ref/explain.sgml @@ -43,6 +43,7 @@ EXPLAIN [ ANALYZE ] [ VERBOSE ] <replaceable class="parameter">statement</replac BUFFERS [ <replaceable class="parameter">boolean</replaceable> ] TIMING [ <replaceable class="parameter">boolean</replaceable> ] SUMMARY [ <replaceable class="parameter">boolean</replaceable> ] + ALL [ <replaceable class="parameter">boolean</replaceable> ] FORMAT { TEXT | XML | JSON | YAML } </synopsis> </refsynopsisdiv> @@ -224,6 +225,16 @@ ROLLBACK; </listitem> </varlistentry> + <varlistentry> + <term><literal>ALL</literal></term> + <listitem> + <para> + Include (or exclude) all of the above settings before examining the rest + of the options. It defaults to <literal>FALSE</literal>. + </para> + </listitem> + </varlistentry> + <varlistentry> <term><literal>FORMAT</literal></term> <listitem> diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index a6c6de78f1..7ad73e4482 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -151,6 +151,26 @@ ExplainQuery(ParseState *pstate, ExplainStmt *stmt, const char *queryString, bool summary_set = false; /* Parse options list. */ + /* First, see whether ALL is set */ + foreach(lc, stmt->options) + { + DefElem *opt = (DefElem *) lfirst(lc); + + if (strcmp(opt->defname, "all") == 0) + { + es->analyze = defGetBoolean(opt); + es->verbose = defGetBoolean(opt); + es->costs = defGetBoolean(opt); + es->buffers = defGetBoolean(opt); + es->settings = defGetBoolean(opt); + timing_set = true; + es->timing = defGetBoolean(opt); + summary_set = true; + es->timing = defGetBoolean(opt); + } + } + + /* If you add another boolean option here, remember to add it above, too */ foreach(lc, stmt->options) { DefElem *opt = (DefElem *) lfirst(lc); @@ -194,6 +214,8 @@ ExplainQuery(ParseState *pstate, ExplainStmt *stmt, const char *queryString, opt->defname, p), parser_errposition(pstate, opt->location))); } + else if (strcmp(opt->defname, "all") == 0) + ; /* Do nothing */ else ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 3dc0e8a4fb..4a69f9711c 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -10704,6 +10704,7 @@ explain_option_elem: explain_option_name: NonReservedWord { $$ = $1; } | analyze_keyword { $$ = "analyze"; } + | ALL { $$ = "all"; } ; explain_option_arg: diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index bcddc7601e..8177f9c6da 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -2862,9 +2862,9 @@ psql_completion(const char *text, int start, int end) * one word, so the above test is correct. */ if (ends_with(prev_wd, '(') || ends_with(prev_wd, ',')) - COMPLETE_WITH("ANALYZE", "VERBOSE", "COSTS", "BUFFERS", + COMPLETE_WITH("ALL", "ANALYZE", "VERBOSE", "COSTS", "BUFFERS", "TIMING", "SUMMARY", "FORMAT"); - else if (TailMatches("ANALYZE|VERBOSE|COSTS|BUFFERS|TIMING|SUMMARY")) + else if (TailMatches("ALL|ANALYZE|VERBOSE|COSTS|BUFFERS|TIMING|SUMMARY")) COMPLETE_WITH("ON", "OFF"); else if (TailMatches("FORMAT")) COMPLETE_WITH("TEXT", "XML", "JSON", "YAML"); @@ -2874,7 +2874,8 @@ psql_completion(const char *text, int start, int end) "VERBOSE"); else if (Matches("EXPLAIN", "(*)") || Matches("EXPLAIN", "VERBOSE") || - Matches("EXPLAIN", "ANALYZE", "VERBOSE")) + Matches("EXPLAIN", "ANALYZE", "VERBOSE") || + Matches("EXPLAIN", "ALL")) COMPLETE_WITH("SELECT", "INSERT", "DELETE", "UPDATE", "DECLARE"); /* FETCH && MOVE */ --------------2.21.0--

view thread (49+ messages)  latest in thread

Message-ID: <20190507075047.GJ28936@fetter.org>
Permalink:  ../20190507075047.GJ28936@fetter.org/
Also on:    postgresql.org/message-id/20190507075047.GJ28936@fetter.org

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: david@fetter.org
  Subject: Re: New EXPLAIN option: ALL
  In-Reply-To: <20190507075047.GJ28936@fetter.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox