Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hsY2Z-0008GS-AL for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Jul 2019 19:44:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hsY2X-0001cH-C6 for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Jul 2019 19:44:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hsY2X-0001cA-3E for pgsql-hackers@lists.postgresql.org; Tue, 30 Jul 2019 19:44:05 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hsY2U-0008Nl-Ml for pgsql-hackers@lists.postgresql.org; Tue, 30 Jul 2019 19:44:04 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x6UJhwd0032571; Tue, 30 Jul 2019 15:43:58 -0400 From: Tom Lane To: Tomas Vondra cc: Pavel Stehule , Adrien Nayrat , PostgreSQL Hackers Subject: Re: idea: log_statement_sample_rate - bottom limit for sampling In-reply-to: <20190727221948.irg6sfqh57dynoc7@development> References: <156292912396.1365.3073279552263868317.pgcf@coridan.postgresql.org> <156292957348.1365.8079060287740507529.pgcf@coridan.postgresql.org> <20190727221948.irg6sfqh57dynoc7@development> Comments: In-reply-to Tomas Vondra message dated "Sun, 28 Jul 2019 00:19:48 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <32569.1564515838.1@sss.pgh.pa.us> Date: Tue, 30 Jul 2019 15:43:58 -0400 Message-ID: <32570.1564515838@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Tomas Vondra writes: > I've started reviewing this patch, thinking that maybe I could get it > committed as it's marked as RFC. In general I agree with having this > fuature, but I think we need to rethink the GUC because the current > approach is just confusing. > ... > What I think we should do instead is to use two minimum thresholds. > 1) log_min_duration_sample - enables sampling of commands, using the > existing GUC log_statement_sample_rate > 2) log_min_duration_statement - logs all commands exceeding this > I think this is going to be much easier for users to understand. I agree with Tomas' idea. > The one difference between those approaches is in how they work with > existing current settings. That is, let's say you have > log_min_duration_statement = 1000 > log_statement_sample_rate = 0.01 > then no queries below 1000ms will be logged, and 1% of longer queries > will be sampled. And with the original config (as proposed in v3 of the > patch), this would still work the same way. > With the new approach (two min thresholds) it'd behave differently, > because we'd log *all* queries longer than 1000ms (not just 1%). And > whether we'd sample any queries (using log_statement_sample_rate) would > depend on how we'd pick the default value for the other threshold. Well, we do not need to have a backwards-compatibility problem here, because we have yet to release a version containing log_statement_sample_rate. I do not think it's too late to decide that v12's semantics for that are broken, and either revert that patch in v12, or back-patch a fix to make it match this idea. regards, tom lane