Re: [PG13] Planning (time + buffers) data structure in explain plan (format text)

Julien Rouhaud <rjuju123@gmail.com>

From: Julien Rouhaud <rjuju123@gmail.com>
To: Justin Pryzby <pryzby@telsasoft.com>
Cc: Pierre Giraud <pierre.giraud@dalibo.com>, pgsql-hackers@lists.postgresql.org, Fujii Masao <fujii@postgresql.org>
Date: 2020-08-19T07:21:33Z
Lists: pgsql-hackers

Attachments

On Tue, Aug 18, 2020 at 10:27:06PM -0500, Justin Pryzby wrote:
> On Fri, Aug 07, 2020 at 02:30:01PM +0200, Pierre Giraud wrote:
> > Hi all,
> > 
> > As far as I understand, in the upcoming version 13, information about
> > buffers used during planning is now available in the explain plan.
> > 
> > […]
> >  Planning Time: 0.203 ms
> >    Buffers: shared hit=14
> > […]
> > 
> > For a matter of consistency, I wonder if it would be possible to format
> > it like the following:
> > 
> > […]
> >  Planning:
> >    Planning Time: 0.203 ms
> >    Buffers: shared hit=14
> 
> Thanks for reporting.  I added this here.
> https://wiki.postgresql.org/wiki/PostgreSQL_13_Open_Items

Thanks Justin!

Hearing no objection, here's a patch to change the output as suggested by
Pierre:

=# explain (analyze, buffers) select * from pg_class;
                                               QUERY PLAN                                              >
------------------------------------------------------------------------------------------------------->
 Seq Scan on pg_class  (cost=0.00..16.86 rows=386 width=265) (actual time=0.020..0.561 rows=386 loops=1)
   Buffers: shared hit=9 read=4
 Planning:
   Planning Time: 4.345 ms
   Buffers: shared hit=103 read=12
 Execution Time: 1.447 ms
(6 rows)

=# explain (analyze, buffers, format json) select * from pg_class;
             QUERY PLAN
-------------------------------------
 [                                  +
   {                                +
     "Plan": {                      +
       "Node Type": "Seq Scan",     +
       "Parallel Aware": false,     +
[...]
       "Temp Written Blocks": 0     +
     },                             +
     "Planning": {                  +
       "Planning Time": 4.494,      +
       "Shared Hit Blocks": 103,    +
       "Shared Read Blocks": 12,    +
       "Shared Dirtied Blocks": 0,  +
       "Shared Written Blocks": 0,  +
       "Local Hit Blocks": 0,       +
       "Local Read Blocks": 0,      +
       "Local Dirtied Blocks": 0,   +
       "Local Written Blocks": 0,   +
       "Temp Read Blocks": 0,       +
       "Temp Written Blocks": 0     +
     },                             +
     "Triggers": [                  +
     ],                             +
     "Execution Time": 1.824        +
   }                                +
 ]
(1 row)

Commits

  1. Fix explain regression test failure.

  2. Rework EXPLAIN for planner's buffer usage.