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 1tVAMx-00636n-6o for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Jan 2025 14:15:44 +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 1tVAMw-004ApJ-MS for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Jan 2025 14:15:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tVAMw-004ApB-Bb for pgsql-hackers@lists.postgresql.org; Tue, 07 Jan 2025 14:15:42 +0000 Received: from forwardcorp1d.mail.yandex.net ([178.154.239.200]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tVAMs-000LAT-07 for pgsql-hackers@postgresql.org; Tue, 07 Jan 2025 14:15:41 +0000 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:b1cb:0:640:2a1e:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 88E2660A08; Tue, 7 Jan 2025 17:15:34 +0300 (MSK) Received: from smtpclient.apple (unknown [2a02:6b8:b081:b687::1:2f]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id WFmPIlLIh0U0-AXWDva8B; Tue, 07 Jan 2025 17:15:33 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1736259334; bh=olwHtyiXcZXny3zfZa11uZHCSamJASlGObFgoyypLbM=; h=Message-Id:To:Date:References:Cc:In-Reply-To:From:Subject; b=DBFcQdbSfT2fSP4ErkUsrdWIRdMT5hMMN5M1VB5KxKckcGaXzMo0Z3V5LkZoZGvNZ cAFfKqUUTLBupH7p2sv8AB4cq+tDDMNJ5+rcQ8j6qJZdbFGZXtwFeODv/9dGwklRRM a8zTsQXO85UHYKmNqWT9B4nah3PCV7zoG7GhquYg= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51.11.1\)) Subject: Re: Sample rate added to pg_stat_statements From: "Andrey M. Borodin" In-Reply-To: <20994d10-ab44-4c6b-91bc-c4675cd2e58e@tantorlabs.com> Date: Tue, 7 Jan 2025 19:15:22 +0500 Cc: Sami Imseih , Alexander Korotkov , Michael Paquier , Greg Sabino Mullane , pgsql-hackers Content-Transfer-Encoding: quoted-printable Message-Id: <9D8A5BC8-A3A5-4DA9-9382-F30D343247D1@yandex-team.ru> 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> To: Ilia Evdokimov X-Mailer: Apple Mail (2.3776.700.51.11.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 7 Jan 2025, at 16:05, Ilia Evdokimov = wrote: >=20 >> 1. This code seems a little different from your patch. It is trying = to avoid engaging PRNG. I'm not sure it's a good idea, but still. Also, = it uses "<=3D", not "<". >>=20 >> xact_is_sampled =3D log_xact_sample_rate !=3D 0 && >> (log_xact_sample_rate =3D=3D 1 || >> pg_prng_double(&pg_global_prng_state) <=3D log_xact_sample_rate); >>=20 > Are we sure we're discussing the same patch? Because these remarks = refer to the 5 version of the patch, which I abandoned due to your = remarks. Yes. v6 has this code + if (nesting_level =3D=3D 0) + current_query_sampled =3D = (pg_prng_double(&pg_global_prng_state) < pgss_sample_rate); while upstream has code that I cited. And logic is slightly different. Best regards, Andrey Borodin.=