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

From: Julien Rouhaud <rjuju123(at)gmail(dot)com>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #16109: Postgres planning time is high across version (Expose buffer usage during planning in EXPLAIN)
Date: 2020-01-24 21:06:11
Message-ID: CAOBaU_ZhmG7FZBH9z28nb7++zQ--FsqX_GcTefXa7oj1yrWnRg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Fri, Jan 24, 2020 at 6:55 AM Justin Pryzby <pryzby(at)telsasoft(dot)com> wrote:
>
> 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(at)anarazel(dot)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

Good idea. Note that you can't use preprocessor concatenation to
generate something else than a token or a number, so the ## can just
be removed here.

Attachment Content-Type Size
show_planning_buffers-v2.diff application/octet-stream 7.8 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Reyna Melara 2020-01-25 00:07:47 Re: BUG #16203: So difficult to set an use postgres
Previous Message Joe Tart 2020-01-24 18:55:04 Re: BUG #16228: Can connect, but cannot open or use tables in LibreOffice Base 6

Browse pgsql-hackers by date

  From Date Subject
Next Message Bossart, Nathan 2020-01-24 21:24:45 Re: Add MAIN_RELATION_CLEANUP and SECONDARY_RELATION_CLEANUP options to VACUUM
Previous Message Ranier Vilela 2020-01-24 20:48:59 [PATCH] /src/backend/access/transam/xlog.c, tiny improvements