Re: track generic and custom plans in pg_stat_statements

From: Sami Imseih <samimseih(at)gmail(dot)com>
To: Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com>
Cc: Greg Sabino Mullane <htamfids(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: track generic and custom plans in pg_stat_statements
Date: 2025-03-06 15:04:35
Message-ID: CAA5RZ0uT1DqOw5X0r0fB68qpYRqNdREv9A8izqQu6k1LMwkByg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Thank you for your patch. It is really useful for tracking the history
> of generic and custom plan usage.

Thanks for the review!

> 1. Is there any reason for the double check of cplan != NULL? It seems
> unnecessary, and we could simplify it to:
>
> -if (cplan && cplan->status == PLAN_CACHE_STATUS_CUSTOM_PLAN)
> +if (cplan->status == PLAN_CACHE_STATUS_CUSTOM_PLAN)

No, it's not necessary and an oversight. removed.

> 2. Should we add Assert(kind == PGSS_EXEC) at this place to ensure that
> generic_plan_calls and custom_plan_calls are only incremented when
> appropriate?
>

I don't think an assert is needed here. There is an assert at the start of
the block for PGSS_EXEC and PGSS_PLAN, but cplan is only available
in the executor.

v4 attached

--
Sami

Attachment Content-Type Size
v4-0001-add-plan_cache-counters-to-pg_stat_statements.patch application/octet-stream 19.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2025-03-06 15:33:33 Re: AIO v2.5
Previous Message Bertrand Drouvot 2025-03-06 14:56:16 Re: Log connection establishment timings