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 1tfcRt-003kbG-JS for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Feb 2025 10:16:02 +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 1tfcRs-00DV5z-Nl for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Feb 2025 10:16:00 +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 1tfcRs-00DV5q-CE for pgsql-hackers@lists.postgresql.org; Wed, 05 Feb 2025 10:16:00 +0000 Received: from forward102a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:d102]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tfcRp-003QFF-09 for pgsql-hackers@postgresql.org; Wed, 05 Feb 2025 10:16:00 +0000 Received: from mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:a7ab:0:640:ee89:0]) by forward102a.mail.yandex.net (Yandex) with ESMTPS id B207860EEE; Wed, 5 Feb 2025 13:15:55 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id pFiN5gPOlmI0-ZajTlglO; Wed, 05 Feb 2025 13:15:54 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tantorlabs.com; s=mail; t=1738750555; bh=43LCrt89j5ph8ofa4/71TSlUYcpmnhxd99cx8dXbUu8=; h=From:In-Reply-To:Cc:Date:References:To:Subject:Message-ID; b=x4tNifMajnmwUo7Eyr9Sa7c1Hmxd+d3R5n3uBAKbCrvFgHBLAkvVWtZxFBNpMHYiS 6307EFuFtwzHSFxVAo3F7uGbuU+iol/HyNUwg5HTz+0uOQCFglI3O/GSzAOzaTHD7J BKPmRzaIimGw9qof3VevmZIpw8Yvm18dm2r1vbWY= Authentication-Results: mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net; dkim=pass header.i=@tantorlabs.com Message-ID: <623db69f-b40a-4d50-b1bd-bb073fcc4336@tantorlabs.com> Date: Wed, 5 Feb 2025 13:15:51 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Sample rate added to pg_stat_statements To: Sami Imseih Cc: Andrey Borodin , Alena Rybakina , Alexander Korotkov , Michael Paquier , Greg Sabino Mullane , pgsql-hackers References: <6cf6270b-e8fa-4d99-b74a-17e781cdf309@tantorlabs.com> <3a27c830-b81f-4560-9774-a87d9b922fbd@tantorlabs.com> <7AD765EF-14DE-4B3E-8282-E82A9B44DBAA@yandex-team.ru> <0c7770bd-9750-4200-a472-bdb262583c2f@tantorlabs.com> <18631d46-1741-4edc-b116-8d9631cdf919@tantorlabs.com> <4f98ec33-c627-4eb4-84f3-9994a0982277@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 04.02.2025 20:59, Sami Imseih wrote: >> To summarize the results of all benchmarks, I compiled them into a table: > Thanks for compiling the benchmark data above. > > The main benefit of this patch will be to give the user > a toggle if they are observing high spinlock contention > due to pg_stat_statements which will likely occur > on larger machines. > > I also did not see this thread [1] mentioned in the thread above, > but one of the reasons pg_stat_statements.track_planning > was turned off by default was due to the additional spinlock > acquire to track the planning stats. Bringing this up as sample_rate > might also be beneficial as well if a user decides to track planning. > > Regards, > > Sami > > [1] https://www.postgresql.org/message-id/flat/2895b53b033c47ccb22972b589050dd9@EX13D05UWC001.ant.amazon.com Thanks for the thread. As we can see, simply enabling or disabling not only track_planning but also other pg-stat_statements parameters is too radical a measure for managing performance. With the introduction of sample_rate,  users now have more flexibility in controlling spinlock contention. This allows them to balance overhead and statistics collection rather than completely disabling the feature. -- Best regards, Ilia Evdokimov, Tantor Labs LLC.