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 1gPhjy-0003Gs-Qd for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Nov 2018 05:41:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gPhjw-0007ZV-7B for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Nov 2018 05:41:24 +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 1gPhjv-0007ZO-Sz for pgsql-hackers@lists.postgresql.org; Thu, 22 Nov 2018 05:41:24 +0000 Received: from mail-it1-x130.google.com ([2607:f8b0:4864:20::130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gPhjs-0007W0-JU for pgsql-hackers@lists.postgresql.org; Thu, 22 Nov 2018 05:41:23 +0000 Received: by mail-it1-x130.google.com with SMTP id v11so12280671itj.0 for ; Wed, 21 Nov 2018 21:41:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-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=hk7PK24ehpsywDpaggQ83dbTtXhmrtj9ahlWtFoRqtw=; b=eVTVg8kiv/69helKYlweUUzZryNUg3WDxf5yMOnALh4gYg/cK6YcyNWPJxJQ1nek7i P4gQ39s3Zp7ChomQP59nVYmIlawYvxWBl2XianV7Djxdm+pht4xiuDwon7caiVEQLrnl J1a6JJUo9TYwbUFMuYL2SKRv1wxvU5N3+jgBzzCOV7rQriXDn8C8+m1t+RAfP6v6Ed8K WRAXRB/9AfAxVqbZwHRkB9gtZjwCMKqcQbjfsuvactVb/T+lhiBAmroKFpjW2OoH4LG1 OxwkKFaoHjTJxwiH1u7CevcZZc4FTecmJmqJAE8ZcDzEWmFET6l0gGMBMNYcEHYT6cwQ Fo+w== 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=hk7PK24ehpsywDpaggQ83dbTtXhmrtj9ahlWtFoRqtw=; b=ojsZxSLpAKq7+fFQUltBtGipsla0oGhoTE8CuCbJxRyyc7VUA6/G/gkS380fgR+PH+ XO1PbVLSYtFec8JMXwF5WsAwPiUv8Mz9K0VK1qSC4SA6fXBY4HUGnaFCAH3doUJgmqYH 0UpgpCyOgKE6HjbhdivIAs7/0GQKY85zpqDzOMhq8evuGsHmREuqIWcxlUlgRNX3LJ1M T6+SRL8V8w0CQCm7xwVroIEMRrZkAIZPnw0iAoAAdBWDPy5s2HgRLrqmDlQl5YhgDXJ8 BFM/rVqJtvB4Ee0fEG2xh42YicUXZa/lRDGnIXLyYIU8pXByzP5+Uo4GmoKLG7N8aZss YoGQ== X-Gm-Message-State: AA+aEWaN31jogjlN/1DDWYt3HawLkqaoNlo/c5KIP6pbMekWnR+8XTpV izjjpuFhI6i5IWFkDlvWn17iQR5xu/g= X-Google-Smtp-Source: AFSGD/WrJi//CrjQOAWXv0K+o1DovAGK3mcj0kkbmYGeiA/AP5jmDr5+j9Ajf7qYlA9K2apUzVInDQ== X-Received: by 2002:a24:dd8f:: with SMTP id t137mr1254424itf.10.1542865278418; Wed, 21 Nov 2018 21:41:18 -0800 (PST) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id l25sm4449155ioj.68.2018.11.21.21.41.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 21:41:17 -0800 (PST) Received: by pryzbyj (Postfix, from userid 1000) id D90D6804FC9; Wed, 21 Nov 2018 23:41:15 -0600 (CST) Date: Wed, 21 Nov 2018 23:41:15 -0600 From: Justin Pryzby To: Patrick Hemmer Cc: pgsql-hackers@lists.postgresql.org, Adrien Nayrat Subject: Re: performance statistics monitoring without spamming logs Message-ID: <20181122054115.GI10913@telsasoft.com> References: <7ffb9dbe-c76f-8ca3-12ee-7914ede872e6@stormcloud9.net> <20180710183828.GB3890@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180710183828.GB3890@telsasoft.com> User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, I'm replying to an old thread from -performance: https://www.postgresql.org/message-id/flat/7ffb9dbe-c76f-8ca3-12ee-7914ede872e6%40stormcloud9.net I was looking at: https://commitfest.postgresql.org/20/1691/ "New GUC to sample log queries" On Tue, Jul 10, 2018 at 01:54:12PM -0400, Patrick Hemmer wrote: > I'm looking for a way of gathering performance stats in a more usable > way than turning on `log_statement_stats` (or other related modules). > The problem I have with the log_*_stats family of modules is that they > log every single query, which makes them unusable in production. Aside > from consuming space, there's also the problem that the log system > wouldn't be able to keep up with the rate. > > There are a couple ideas that pop into mind that would make these stats > more usable: > 1. Only log when the statement would otherwise already be logged. Such > as due to the `log_statement` or `log_min_duration_statement` settings. ..but instead came back to this parallel thread and concluded that I'm interested in exactly that behavior: log_statement_stats only if log_min_duration_statement exceeded. If there's agreement that's desirable behavior, should I change log_statement_stats to a GUC (on/off/logged) ? Or, would it be reasonable to instead change the existing behavior of log_statement_stats=on to mean what I want: only log statement stats if statement is otherwise logged. If log_statement_stats is considered to be a developer option, most likely to be enabled either in a development or other segregated or non-production environment, or possibly for only a single session for diagnostics. My own use case is that I'd like to know if a longrunning query was doing lots of analytics (aggregation/sorting), or possibly spinning away on a nested nested loop. But I only care about the longest queries, and then probably look at the ratio of user CPU/clock time. Justin