Re: Sample rate added to pg_stat_statements

From: Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com>
To: Alena Rybakina <a(dot)rybakina(at)postgrespro(dot)ru>, Sami Imseih <samimseih(at)gmail(dot)com>
Cc: Alexander Korotkov <aekorotkov(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Greg Sabino Mullane <htamfids(at)gmail(dot)com>, "Andrey M(dot) Borodin" <x4mmm(at)yandex-team(dot)ru>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Sample rate added to pg_stat_statements
Date: 2025-01-14 12:00:46
Message-ID: 3a27c830-b81f-4560-9774-a87d9b922fbd@tantorlabs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 09.01.2025 22:13, Alena Rybakina wrote:
> Hi! Thank you for the work with this subject.
>
> I looked at your patch and noticed that this part of the code is
> repeated several times:
>
> if (nesting_level == 0)
>     {
>         if (!IsParallelWorker())
>             current_query_sampled =
> pg_prng_double(&pg_global_prng_state) < pgss_sample_rate;
>         else
>             current_query_sampled = false;
>
>     }
>
> I think you should put this in a function like
> update_current_query_sampled. I've attached a diff file with the changes.

There was redundant checking of nesting_level, so I removed one of them.
The fixed version is included in patch v10.

Alena, Sami – I apologize for not including you in the previous email.
If you're interested in this approach, I'm open to any suggestions.

[0]:
https://www.postgresql.org/message-id/1b13d748-5e98-479c-9222-3253a734a038%40tantorlabs.com

--
Best regards,
Ilia Evdokimov,
Tantor Labs LLC.

Attachment Content-Type Size
v10-0001-Allow-setting-sample-ratio-for-pg_stat_statements.patch text/x-patch 8.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hayato Kuroda (Fujitsu) 2025-01-14 12:12:50 RE: Replace current implementations in crypt() and gen_salt() to OpenSSL
Previous Message Alvaro Herrera 2025-01-14 12:00:22 Re: [WIP]Vertical Clustered Index (columnar store extension) - take2