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 1tVdYL-00ACoV-Cg for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Jan 2025 21:25:25 +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 1tVdYK-007JT9-Pd for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Jan 2025 21:25:24 +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 1tVdYK-007JT1-Fc for pgsql-hackers@lists.postgresql.org; Wed, 08 Jan 2025 21:25:24 +0000 Received: from forward103a.mail.yandex.net ([178.154.239.86]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tVdYG-000aXm-13 for pgsql-hackers@postgresql.org; Wed, 08 Jan 2025 21:25:23 +0000 Received: from mail-nwsmtp-smtp-production-main-55.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-55.vla.yp-c.yandex.net [IPv6:2a02:6b8:c0d:20a:0:640:1f30:0]) by forward103a.mail.yandex.net (Yandex) with ESMTPS id 1D31F60E6C; Thu, 9 Jan 2025 00:25:17 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-55.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id FPukR46OpSw0-0QtQN0dj; Thu, 09 Jan 2025 00:25:16 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tantorlabs.com; s=mail; t=1736371516; bh=vJTpAwWh6Xr79WVWDD2+yRLKxtnemOn9BeWwZkxs3+w=; h=In-Reply-To:Cc:Date:References:To:From:Subject:Message-ID; b=Co3Jr+XtYibL54YZLgzkDOi3WjqR+ClgG8q1zqhbIJmqOt3PVeTRZu6peDQUCE1B8 KdO7ck98rVSTGusXBtYrLSU5PevPUbq9knvSMlUfcxDGkJ12YozeoIgqK9G7q3QUbc xWorHy3G30wB5JXazORyEwxpQt8Zi8rgLtiGndBM= Authentication-Results: mail-nwsmtp-smtp-production-main-55.vla.yp-c.yandex.net; dkim=pass header.i=@tantorlabs.com Message-ID: <9af7cb4e-d191-421f-85a2-22d8c406b47a@tantorlabs.com> Date: Thu, 9 Jan 2025 00:25:15 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Sample rate added to pg_stat_statements From: Ilia Evdokimov To: Sami Imseih , "Andrey M. Borodin" Cc: Alexander Korotkov , Michael Paquier , Greg Sabino Mullane , 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 In-Reply-To: <6cf6270b-e8fa-4d99-b74a-17e781cdf309@tantorlabs.com> 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 08.01.2025 22:39, Ilia Evdokimov wrote: > > After the changes in v9-patch, won’t all the necessary queries now be > normalized? Since there are no longer any restrictions in the parser > hook, queries will be normalized as usual, and pgss_planner, > pgss_ExecutorStart, and ExecutorEnd will simply fetch them from > 'pgss_query_texts.stat' file. > > For now, this seems like the simplest approach instead of making > JumbleState available to other hooks. Moreover, if we do proceed with > that, we might be able to remove the 'pgss_query_texts.stat' file > altogether and more other improvements. In my view, if no other > options arise, we should address making JumbleState available to other > hooks in a separate thread. If you have any suggestions, I'm always > open to feedback. > > I attached v9 patch with changes and test above. Unfortunately, these changes do not achieve the intended sampling goal. I looked into this more deeply: while the sampled-out queries do not appear in pg_stat_statements, an entry is still allocated in the hash table after normalization, which, in my view, should not happen when sampling is in effect. Therefore, patch v9 is unlikely to meet our needs. -- Best regards, Ilia Evdokimov, Tantor Labs LLC.