Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tVzip-00DIMI-HD for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Jan 2025 21:05:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tVzio-008fBv-Sm for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Jan 2025 21:05:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tVzio-008fBm-GY for pgsql-hackers@lists.postgresql.org; Thu, 09 Jan 2025 21:05:42 +0000 Received: from forward101d.mail.yandex.net ([178.154.239.212]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tVzik-000nMz-1p for pgsql-hackers@postgresql.org; Thu, 09 Jan 2025 21:05:41 +0000 Received: from mail-nwsmtp-smtp-production-main-99.klg.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-99.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:26a5:0:640:547b:0]) by forward101d.mail.yandex.net (Yandex) with ESMTPS id F0C32609EC; Fri, 10 Jan 2025 00:05:35 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-99.klg.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id X5vHXL5OduQ0-Co0hJF9G; Fri, 10 Jan 2025 00:05:35 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tantorlabs.com; s=mail; t=1736456735; bh=wKXwqGtktHczO9z//B0RqFrLcwpFXMIsesayUDi4GJU=; h=From:In-Reply-To:Cc:Date:References:To:Subject:Message-ID; b=IJMH4SDQsJDRa5+67Bfb8gIM8tzGcxu9TwtnqIIlBgs/DHI+EVdhAlcwA9npw0fQJ kfUHJ6YAKtzEupXGl1hzMb0ImyEjifXWJIe6WAgQ8s7rDbCZDgJMKV07DZlY0LaZcO lO1hHVr7RDSuy5qlAWyDy5tQ8J7GvjqE52p+PYr4= Authentication-Results: mail-nwsmtp-smtp-production-main-99.klg.yp-c.yandex.net; dkim=pass header.i=@tantorlabs.com Message-ID: Date: Fri, 10 Jan 2025 00:05:33 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Sample rate added to pg_stat_statements To: Alena Rybakina Cc: Alexander Korotkov , Michael Paquier , Greg Sabino Mullane , "Andrey M. Borodin" , Sami Imseih , pgsql-hackers References: <6707FCA9-FD1A-4609-A1A6-142456C14E0C@yandex-team.ru> <320a31e6-4c91-438b-ab17-8a1d72384727@tantorlabs.com> <52e5e3aa-066a-4daf-8d65-77c34a2f0d98@tantorlabs.com> <6482A576-4465-4E46-A42C-F1767E8DDE30@yandex-team.ru> <20994d10-ab44-4c6b-91bc-c4675cd2e58e@tantorlabs.com> <9D8A5BC8-A3A5-4DA9-9382-F30D343247D1@yandex-team.ru> <6cf6270b-e8fa-4d99-b74a-17e781cdf309@tantorlabs.com> Content-Language: en-US From: Ilia Evdokimov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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. > Agree, thanks. -- Best regards, Ilia Evdokimov, Tantor Labs LLC.