| From: | Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com> | 
|---|---|
| To: | Julien Rouhaud <rjuju123(at)gmail(dot)com>, Nikolay Samokhvalov <samokhvalov(at)gmail(dot)com> | 
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> | 
| Subject: | Re: pg_stat_statements oddity with track = all | 
| Date: | 2020-12-02 06:52:37 | 
| Message-ID: | dc48d183-65a2-8f12-3581-ab8f3faeab8b@oss.nttdata.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
On 2020/12/02 15:32, Julien Rouhaud wrote:
> On Tue, Dec 01, 2020 at 10:08:06PM -0800, Nikolay Samokhvalov wrote:
>> On Tue, Dec 1, 2020 at 8:05 PM Julien Rouhaud <rjuju123(at)gmail(dot)com> wrote:
>>
>>> Someone raised an interested point recently on pg_stat_kcache extension for
>>> handling nested statements, which also applies to pg_stat_statements.
>>>
>> ...
>>
>>> The only idea I have for that is to add a new field to entry key, for
>>> instance
>>> is_toplevel.
>>
>>
>> This particular problem often bothered me when dealing with
>> pg_stat_statements contents operating under "track = all" (especially when
>> performing the aggregated analysis, like you showed).
>>
>> I think the idea of having a flag to distinguish the top-level entries is
>> great.
>>
> 
> Ok!
> 
>>> The immediate cons is obviously that it could amplify quite a lot
>>> the number of entries tracked, so people may need to increase
>>> pg_stat_statements.max to avoid slowdown if that makes them reach frequent
>>> entry eviction.
>>>
>>
>> If all top-level records in pg_stat_statements have "true" in the new
>> column (is_toplevel), how would this lead to the need to increase
>> pg_stat_statements.max? The number of records would remain the same, as
>> before extending pg_stat_statements.
> 
> If the same query is getting executed both at top level and as a nested
> statement, two entries will then be created.  That's probably unlikely for
> things like RI trigger queries, but I don't know what to expect for client
> application queries.
Just idea; instead of boolean is_toplevel flag, what about
counting the number of times when the statement is executed
in toplevel, and also in nested level?
Regards,
-- 
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Thomas Munro | 2020-12-02 06:56:04 | Re: Recent eelpout failures on 9.x branches | 
| Previous Message | Fujii Masao | 2020-12-02 06:33:05 | Re: autovac issue with large number of tables |