Re: pgsql: Move pg_stat_statements query jumbling to core. - Mailing list pgsql-committers

From Julien Rouhaud
Subject Re: pgsql: Move pg_stat_statements query jumbling to core.
Date
Msg-id 20210408061102.xripofnfvqt7qcrg@nol
Whole thread Raw
In response to Re: pgsql: Move pg_stat_statements query jumbling to core.  (Julien Rouhaud <rjuju123@gmail.com>)
Responses Re: pgsql: Move pg_stat_statements query jumbling to core.
List pgsql-committers
On Thu, Apr 08, 2021 at 01:22:49PM +0800, Julien Rouhaud wrote:
> Le jeu. 8 avr. 2021 à 13:17, Andres Freund <andres@anarazel.de> a écrit :
> 
> >
> > This - or something in the vicinity - seems to break running the
> > regression tests with force_parallel_mode=regress. There's lots of
> > differences like
> >
> >  SELECT query, calls, rows FROM pg_stat_statements ORDER BY query COLLATE
> > "C";
> >                                      query
> >      | calls | rows
> >
> >  ------------------------------------------------------------------------------+-------+------
> >   SELECT (i + $2 + $3)::INTEGER
> >     |     2 |    2
> >   SELECT (i + $2)::INTEGER LIMIT $3
> >     |     2 |    2
> > - SELECT PLUS_ONE($1)
> >     |     2 |    2
> > - SELECT PLUS_TWO($1)
> >     |     2 |    2
> > - SELECT pg_stat_statements_reset()
> >     |     1 |    1
> > + SELECT PLUS_ONE($1)
> >     |     4 |    4
> > + SELECT PLUS_TWO($1)
> >     |     4 |    4
> > + SELECT pg_stat_statements_reset();
> 
> oh, I think it's because parallel workers now have the queryid of the main
> query. Probably ignoring parallel workers in the executor end hook will fix
> the problem. I'll look at it as soon as I will be back home.

That was indeed the problem.  I think the best is to entirely ignore parallel
workers in pg_stat_statements, as done in attached patch, which fixes the
regression tests with force_parallel_mode = regress.

Attachment

pgsql-committers by date:

Previous
From: Thomas Munro
Date:
Subject: pgsql: Provide ReadRecentBuffer() to re-pin buffers by ID.
Next
From: Tom Lane
Date:
Subject: Re: pgsql: autovacuum: handle analyze for partitioned tables