Re: BUG #16109: Postgres planning time is high across version(Expose buffer usage during planning in EXPLAIN) - Mailing list pgsql-hackers

From Justin Pryzby
Subject Re: BUG #16109: Postgres planning time is high across version(Expose buffer usage during planning in EXPLAIN)
Date
Msg-id 20200124055534.GM13621@telsasoft.com
Whole thread Raw
In response to Re: BUG #16109: Postgres planning time is high across version - 10.6vs 10.10  (Julien Rouhaud <rjuju123@gmail.com>)
Responses Re: BUG #16109: Postgres planning time is high across version (Exposebuffer usage during planning in EXPLAIN)  (Julien Rouhaud <rjuju123@gmail.com>)
List pgsql-hackers
On Wed, Nov 13, 2019 at 11:39:04AM +0100, Julien Rouhaud wrote:
> (moved to -hackers)
> 
> On Tue, Nov 12, 2019 at 9:55 PM Andres Freund <andres@anarazel.de> wrote:
> >
> > This last point is more oriented towards other PG developers: I wonder
> > if we ought to display buffer statistics for plan time, for EXPLAIN
> > (BUFFERS). That'd surely make it easier to discern cases where we
> > e.g. access the index and scan a lot of the index from cases where we
> > hit some CPU time issue. We should easily be able to get that data, I
> > think, we already maintain it, we'd just need to compute the diff
> > between pgBufferUsage before / after planning.
> 
> That would be quite interesting to have.  I attach as a reference a
> quick POC patch to implement it:

+1

+    result.shared_blks_hit = stop->shared_blks_hit - start->shared_blks_hit;
+    result.shared_blks_read = stop->shared_blks_read - start->shared_blks_read;
+    result.shared_blks_dirtied = stop->shared_blks_dirtied -
+        start->shared_blks_dirtied;
[...]

I think it would be more readable and maintainable using a macro:

#define CALC_BUFF_DIFF(x) result.##x = stop->##x - start->##x
CALC_BUFF_DIFF(shared_blks_hit);
CALC_BUFF_DIFF(shared_blks_read);
CALC_BUFF_DIFF(shared_blks_dirtied);
...
#undefine CALC_BUFF_DIFF




pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [Patch] pg_rewind: options to use restore_command fromrecovery.conf or command line
Next
From: Michael Paquier
Date:
Subject: Re: Add pg_file_sync() to adminpack