Re: Expose Parallelism counters planned/execute in pg_stat_statements

From: Julien Rouhaud <rjuju123(at)gmail(dot)com>
To: Anthony Sotolongo <asotolongo(at)gmail(dot)com>
Cc: Justin Pryzby <pryzby(at)telsasoft(dot)com>, pgsql-hackers(at)postgresql(dot)org, daymelbonne(at)gmail(dot)com
Subject: Re: Expose Parallelism counters planned/execute in pg_stat_statements
Date: 2022-07-22 16:08:30
Message-ID: 20220722160830.f7ykmhjao2m2xwtm@jrouhaud
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Fri, Jul 22, 2022 at 11:17:52AM -0400, Anthony Sotolongo wrote:
>
> On 21-07-22 20:35, Justin Pryzby wrote:
> > On Thu, Jul 21, 2022 at 06:26:58PM -0400, Anthony Sotolongo wrote:
> > > Hi all:
> > > Here's a patch to add counters about  planned/executed  for parallelism  to
> > > pg_stat_statements, as a way to follow-up on if the queries are
> > > planning/executing with parallelism, this can help to understand if you have
> > > a good/bad configuration or if your hardware is enough
> > +1, I was missing something like this before, but it didn't occur to me to use
> > PSS:
>
> First of all, thanks for review the the patch and for the comments
>
>
> > https://www.postgresql.org/message-id/20200310190142.GB29065@telsasoft.com
> > > My hope is to answer to questions like these:
> > >
> > > . is query (ever? usually?) using parallel paths?
> > > . is query usefully using parallel paths?
> > > . what queries are my max_parallel_workers(_per_process) being used for ?
> > > . Are certain longrunning or frequently running queries which are using
> > > parallel paths using all max_parallel_workers and precluding other queries
> > > from using parallel query ? Or, are semi-short queries sometimes precluding
> > > longrunning queries from using parallelism, when the long queries would
> > > better benefit ?
> > This patch is storing the number of times the query was planned/executed using
> > parallelism, but not the number of workers. Would it make sense to instead
> > store the the *number* of workers launched/planned ? Otherwise, it might be
> > that a query is consistently planned to use a large number of workers, but then
> > runs with few. I'm referring to the fields shown in "explain/analyze". (Then,
> > the 2nd field should be renamed to "launched").
> >
> > Workers Planned: 2
> > Workers Launched: 2
>
> The main idea of the patch is to store the number of times the statements
> were planned and executed in parallel, not the number of workers used in the
> execution. Of course, what you mention can be helpful, it will be given a
> review to see how it can be achieved

I think you would need both information.

With your current patch it only says if the plan and execution had parallelism
enabled, but not if it could actually use with parallelism at all. It gives
some information, but it's not that useful on its own.

Also, a cumulated number of workers isn't really useful if you don't know what
fraction of the number of executions (or planning) they refer to.

That being said, I'm not sure how exactly the information about the number of
workers can be exposed, as there might be multiple gathers per plan and AKAIK
they can run at different part of the query execution. So in some case having
a total of 3 workers planned means that you ideally needed 3 workers available
at the same time, and in some other case it might be only 2 or even 1.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Önder Kalacı 2022-07-22 16:15:16 Re: [PATCH] Use indexes on the subscriber when REPLICA IDENTITY is full on the publisher
Previous Message Pavel Borisov 2022-07-22 15:56:20 Re: Custom tuplesorts for extensions