Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fcxXI-0000bl-6k for pgsql-performance@arkaria.postgresql.org; Tue, 10 Jul 2018 18:38:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fcxXG-0001a2-0R for pgsql-performance@arkaria.postgresql.org; Tue, 10 Jul 2018 18:38:50 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fcxX1-0000JM-Fe for pgsql-performance@lists.postgresql.org; Tue, 10 Jul 2018 18:38:35 +0000 Received: from mail-it0-x241.google.com ([2607:f8b0:4001:c0b::241]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fcxWw-0003HL-NS for pgsql-performance@lists.postgresql.org; Tue, 10 Jul 2018 18:38:32 +0000 Received: by mail-it0-x241.google.com with SMTP id g4-v6so88358iti.1 for ; Tue, 10 Jul 2018 11:38:30 -0700 (PDT) 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=rYr1SbXD4xfGDLl/6w6j01BJslTRm+H5eepIM/jXHJU=; b=gyUokt8eAoYxiSO+eAUpUihwEu3TJO23H83JQ0TuHAQMKNPnUfc1UY3+47jd6laFch cfKcs3ZrWPogGGYLq09aWOgTo/u4Uhh5R5K2cqOsmVInpYohaTYw64WF2hsSBGQWiMUZ HVmPJ7oeYiUL70PtSZroU4mtHzXJVGxPNOv1pgose+g4k4iia1/Z8wZR5s1eXoQMz1d/ tJ5snIW7q09D5CsdGPJUrdNyEtct5dJFMbxN+HsK46bzluCc5MO1mN6T6ymVPrIgUbYI SVfUC18CFEf//2+lwmpccFhogrQ9aZVdCA2Tm13VNduej9x7hNpIXI2hbjyH35GSAAHk lxgw== 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=rYr1SbXD4xfGDLl/6w6j01BJslTRm+H5eepIM/jXHJU=; b=fin4TFcrQ4vUlaccW9OVJcMmhCmOMZeHfh5gLsAiu3I0WO8FXRK12nGsykjhjV0JBe L8p9wH7VcM7tyLKDUZH1JZaR8kIPd2XeVCB+iryReni1jJRBeHm+e7E4y/ySibF5R/az +pti0V/sWNlFufXXhnEuqoNdbJZ9EYoBAQUH1c8hKSuJ9z7/WNlcc59gw+Cy9ctKZjdH 0gX2Scuk43ro93gyN+uKvfvVsOaF/g2ZfbMUaQ4l/jrj5LUj/HpmxTVXMS9jYL+J5oFy BZ/+rpdPbX72faRJWoanLfYsgspYrGub+Z0L2EwrNPcWXyfiUmWoEQphQo5u4C36qH4d FJNg== X-Gm-Message-State: AOUpUlHRfasRl5m3p6jFX7Basv2Ib6pXj+thjYH/Fm6ZiAo7H16yRyo4 jMcGz7io8GGAbmNOnzfoJDN9Rinyyhc= X-Google-Smtp-Source: AAOMgpeuwDiiqSldoRXQiRPns4RFBlIRcUd0PpXDZd0a93VWWtBUqVQmEKq64A5wuFYetZJ34ucRLA== X-Received: by 2002:a24:808b:: with SMTP id g133-v6mr10807002itd.80.1531247909325; Tue, 10 Jul 2018 11:38:29 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id g6-v6sm16619iti.0.2018.07.10.11.38.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jul 2018 11:38:28 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id 395F9804E78; Tue, 10 Jul 2018 13:38:28 -0500 (CDT) Date: Tue, 10 Jul 2018 13:38:28 -0500 From: Justin Pryzby To: Patrick Hemmer Cc: pgsql-performance@lists.postgresql.org, Adrien Nayrat Subject: Re: performance statistics monitoring without spamming logs Message-ID: <20180710183828.GB3890@telsasoft.com> References: <7ffb9dbe-c76f-8ca3-12ee-7914ede872e6@stormcloud9.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7ffb9dbe-c76f-8ca3-12ee-7914ede872e6@stormcloud9.net> User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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. Did you see: (Added Adrien to Cc); https://commitfest.postgresql.org/18/1691/ I don't think the existing patch does what you want, but perhaps all that's needed is this: if (save_log_statement_stats) + if (log_sample_rate==1 || was_logged) ShowUsage("EXECUTE MESSAGE STATISTICS"); In any case, I'm thinking that your request could/should be considered by whatever future patch implements sampling (if not implemented/included in the patch itself). If that doesn't do what's needed, that patch might still be a good crash course in how to start implementing what you need (perhaps on top of that patch). > 2. Make stats available in `pg_stat_statements` (or alternate view that > could be joined on). The block stats are already available here, but > others like CPU usage, page faults, and context switches are not. pg_stat_statements is ./contrib/pg_stat_statements/pg_stat_statements.c which is 3k LOC. getrusage stuff and log_*_stat stuff is in src/backend/tcop/postgres.c Justin