Re: Planning counters in pg_stat_statements (using pgss_store)

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Julien Rouhaud <rjuju123(at)gmail(dot)com>
Cc: Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com>, Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, legrand legrand <legrand_legrand(at)hotmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Magnus Hagander <magnus(at)hagander(dot)net>
Subject: Re: Planning counters in pg_stat_statements (using pgss_store)
Date: 2020-05-21 07:17:16
Message-ID: 20200521071716.GM2355@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, May 21, 2020 at 08:49:53AM +0200, Julien Rouhaud wrote:
> On Tue, May 19, 2020 at 4:29 AM Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com> wrote:
>> Thanks for the excellent extension. I want to add 5 more fields to satisfy the
>> following requirements.
>>
>> int subplan; /* No. of subplan in this query */
>> int subquery; /* No. of subquery */
>> int joincnt; /* How many relations are joined */
>> bool hasagg; /* if we have agg function in this query */
>> bool hasgroup; /* has group clause */
>
> Most of those fields can be computed using the raw sql satements. Why
> not adding functions like query_has_agg(querytext) to get the
> information from pgss stored query text instead?

Yeah I personally find concepts related only to the query string
itself not something that needs to be tied to pg_stat_statements.
While reading about those five new fields, I am also wondering how
this stuff would work with CTEs. Particularly, should the hasagg or
hasgroup flags be set only if the most outer query satisfies a
condition? What if an inner query satisfies a condition but not an
outer query? Should joincnt just be the sum of all the joins done in
all queries, including subqueries?
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message wenjing zeng 2020-05-21 07:28:28 Re: [bug] Table not have typarray when created by single user mode
Previous Message John Naylor 2020-05-21 07:12:06 speed up unicode normalization quick check