Record queryid when auto_explain.log_verbose is on

torikoshia <torikoshia@oss.nttdata.com>

From: torikoshia <torikoshia@oss.nttdata.com>
To: Pgsql Hackers <pgsql-hackers@postgresql.org>
Date: 2023-01-16T12:36:59Z
Lists: pgsql-hackers

Attachments

Hi,

As far as I read the manual below, auto_explain.log_verbose should 
record logs equivalent to VERBOSE option of EXPLAIN.

> -- https://www.postgresql.org/docs/devel/auto-explain.html
> auto_explain.log_verbose controls whether verbose details are printed 
> when an execution plan is logged; it's equivalent to the VERBOSE option 
> of EXPLAIN.

However, when compute_query_id is on, query identifiers are only printed 
when using VERBOSE option of EXPLAIN.

EXPLAIN VERBOSE:
```
=# show auto_explain.log_verbose;
  auto_explain.log_verbose
--------------------------
  on
(1 row)

=# show compute_query_id;
  compute_query_id
------------------
  on
(1 row)

=# explain verbose select 1;
                 QUERY PLAN
------------------------------------------
  Result  (cost=0.00..0.01 rows=1 width=4)
    Output: 1
  Query Identifier: -1801652217649936326
(3 rows)
```

auto_explain:
```
LOG:  00000: duration: 0.000 ms  plan:
         Query Text: explain verbose select 1;
         Result  (cost=0.00..0.01 rows=1 width=4)
           Output: 1
```

Attached patch makes auto_explain also print query identifiers.

What do you think?

-- 
Regards,

--
Atsushi Torikoshi
NTT DATA CORPORATION

Commits

  1. Make auto_explain print the query identifier in verbose mode