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 1hrV2n-0000gZ-PT for pgsql-hackers@arkaria.postgresql.org; Sat, 27 Jul 2019 22:20:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hrV2k-0002rW-KY for pgsql-hackers@arkaria.postgresql.org; Sat, 27 Jul 2019 22:19:58 +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 1hrV2k-0002rJ-C9 for pgsql-hackers@lists.postgresql.org; Sat, 27 Jul 2019 22:19:58 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hrV2h-00080h-Bj for pgsql-hackers@lists.postgresql.org; Sat, 27 Jul 2019 22:19:57 +0000 Received: by mail-wm1-x343.google.com with SMTP id 207so50728685wma.1 for ; Sat, 27 Jul 2019 15:19:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=AOyQ+ApgbBImnGwCtt2wjP5AIyOgUL4nV4ccDc8/FPg=; b=rwwUgq7CgbDi3V1zO/CZeutMaLKqkeuqVhsqRlXfJgGBok1iuQTg47ANeK/IahxraV JSWvQtjKHzFOrgaIe1MHVnGgJmaPlcpSqBwhbiP75nQlY2rURwX1IMfaPeHI+lU7H6GE i6Vjw+9Iqx2de1Eko7K9imnJmwv4az6M2NohbOeY+jfQWHfzv2BMrF7rkEvwEEGa+7eY g+kPq4hJCXCYqpKgzssN7BO4so+rbGigtyeNQtydEykcvnbdh7RbRqhMNvfZZPPUXmpB 4w096x31V69BsvsE86wPAqzn+T5vUARvrsQMpMiSsRbKqomOAGH/+YUexWrqNdSvjR5e KH1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=AOyQ+ApgbBImnGwCtt2wjP5AIyOgUL4nV4ccDc8/FPg=; b=C6fxkfGoAQ53DI4Eg4fGyCeV0tDVOv//ozXjf6XEtPuIqJoi2OxymAW+w4sdgYDKh0 o2+Ok7SUEhejNHx/RJkfBZPVnhIL2urybUPCAf6jhmwA2dna5DycYzzXNCeqNuvGGU5z 5cqwOWEBX0sUkhLkgt0mKRIXzQ4IujXSCSbGDy+Xeorp3IQUN1TjF3tFc5FaIWOA2NmR SERNK+yzymAtJw4snD0PlLwFaX5MRytdCcCRKFyB7sX2q5PW1lYf2M6njj+d5QM0v0i1 MLMXx3QHf8gv9aM407TOCBkijYfXqEIev/Gp1mUNROtyca+F7SYo7rEzD5IkPsSk2ina 3q4g== X-Gm-Message-State: APjAAAUnk7ULR3n1PF+G3LqUJgPBTqywYdggDwFSuy3F6w0hKAdZz4+F GALxfNFdiaVlrG0ktbAv8JOaDQ== X-Google-Smtp-Source: APXvYqwcbBSulrGyZiDGwNgSmtVlNExH2aj4IvdcJVWHPQUeVPlS7c0Gk1mjbI5j9l3s1o6ZDsvlWA== X-Received: by 2002:a1c:f116:: with SMTP id p22mr89455722wmh.70.1564265990310; Sat, 27 Jul 2019 15:19:50 -0700 (PDT) Received: from localhost (ip-86-49-253-160.net.upcbroadband.cz. [86.49.253.160]) by smtp.gmail.com with ESMTPSA id j17sm91880533wrb.35.2019.07.27.15.19.49 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 27 Jul 2019 15:19:49 -0700 (PDT) Date: Sun, 28 Jul 2019 00:19:48 +0200 From: Tomas Vondra To: Pavel Stehule Cc: Adrien Nayrat , PostgreSQL Hackers Subject: Re: idea: log_statement_sample_rate - bottom limit for sampling Message-ID: <20190727221948.irg6sfqh57dynoc7@development> References: <156292912396.1365.3073279552263868317.pgcf@coridan.postgresql.org> <156292957348.1365.8079060287740507529.pgcf@coridan.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716-1444-295967 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, 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. The way the current patch works is that we have three GUCs: log_min_duration_statement log_statement_sample_limit log_statement_sample_rate and it essentially works like this: - If the duration exceeds log_min_duration_statement, we start sampling the commands with log_statement_sample rate. - If the duration exceeds log_statement_sample_limit, we just log the command every time (i.e. we disable sampling, using sample rate 1.0). IMO that's bound to be confusing for users, because one threshold behaves as minimum while the other behaves as maximum. 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. 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. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services