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 1tUpUO-00365Z-54 for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Jan 2025 15:58:00 +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 1tUpUM-009s6J-Ck for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Jan 2025 15:57:58 +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 1tUpUM-009s69-3Z for pgsql-hackers@lists.postgresql.org; Mon, 06 Jan 2025 15:57:57 +0000 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tUpUI-000AwD-1s for pgsql-hackers@postgresql.org; Mon, 06 Jan 2025 15:57:56 +0000 Received: from mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:2513:0:640:e765:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 8641660DD1; Mon, 6 Jan 2025 18:57:52 +0300 (MSK) Received: from smtpclient.apple (unknown [2a02:6b8:b081:b431::1:7]) by mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id pvmVOQBIgqM0-T6UNTA4m; Mon, 06 Jan 2025 18:57:51 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1736179071; bh=mPWQ2XCODsTD8Jb3NwmxuvyVdcV5nEdw0V6sJsYW0gE=; h=Message-Id:To:Date:References:Cc:In-Reply-To:From:Subject; b=aWMgftUs0nUePMljhyGQQSpZ3yA8EYLrm04EDf37tqz3/b1Y0aOrL33usxWmc4C3Y bu9/yEI7LF+MMq0GKf+jljsD0h9qbb5XSVA4M4c9epsoSScbJWC10dKPgLidCRSa2B mcLVj5wD2/TA4qPX0UMT7pNX0FJylvFCTDeuyzYI= Authentication-Results: mail-nwsmtp-smtp-corp-main-26.myt.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: <52e5e3aa-066a-4daf-8d65-77c34a2f0d98@tantorlabs.com> Date: Mon, 6 Jan 2025 20:57:40 +0500 Cc: Alexander Korotkov , Michael Paquier , Greg Sabino Mullane , pgsql-hackers Content-Transfer-Encoding: quoted-printable Message-Id: <6482A576-4465-4E46-A42C-F1767E8DDE30@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> 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 6 Jan 2025, at 15:50, Ilia Evdokimov = wrote: >=20 > Any suggestions for improvements? The patch looks good to me, just a few nits. 0. Perhaps, we could have a test for edge values of 0 and 1. I do not = insist, just an idea to think about. 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 "<". 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); Thanks! Best regards, Andrey Borodin.=