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 1fcwqD-00073F-Bo for pgsql-performance@arkaria.postgresql.org; Tue, 10 Jul 2018 17:54:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fcwqB-00079C-Nv for pgsql-performance@arkaria.postgresql.org; Tue, 10 Jul 2018 17:54:19 +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 1fcwqA-00078v-Cv for pgsql-performance@lists.postgresql.org; Tue, 10 Jul 2018 17:54:19 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fcwq7-0002Iw-AB for pgsql-performance@lists.postgresql.org; Tue, 10 Jul 2018 17:54:17 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id D100021E44 for ; Tue, 10 Jul 2018 13:54:13 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 10 Jul 2018 13:54:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=JbBzZzeWGHv5E4G70mobzDQkELu58EERSXS4g1Iev6Y=; b=pj4DyUPW OJALTNFRf9SZliqcz8rHTEWO81o5UtTRf2GRlfhMTRnUxVAfbVBTjfMoktjBihmq kU4KJSo+jaqOS9EwsEbwNqhF0HzPg09B1jh9U9ZaxbQxZNZNt8EyP0F6Wl2VTCun Ys+zd1fjBIeXhzE1a5QKsw3VkjqHiSiIy3hepikdOK2fyjjFHgiadz+HFhrGVexf Q3LCcWECK9D581vHAy2cxd1Aa8YiEA5kczleDCm/fG8rNxdHREt5jqV0LesW6ODc ZhJhitVresPlYps+1tV8ZNAEIKOVS1OLUAc8vX5e+iu6V0i2x3zIBmokVfijdYEZ TMgnyFgmjJn/pA== X-ME-Proxy: X-ME-Sender: Received: from fll1000539l-2.local (unknown [45.73.149.202]) by mail.messagingengine.com (Postfix) with ESMTPA id 6F36EE4627 for ; Tue, 10 Jul 2018 13:54:13 -0400 (EDT) To: pgsql-performance@lists.postgresql.org From: Patrick Hemmer Subject: performance statistics monitoring without spamming logs Openpgp: preference=signencrypt Message-ID: <7ffb9dbe-c76f-8ca3-12ee-7914ede872e6@stormcloud9.net> Date: Tue, 10 Jul 2018 13:54:12 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------BA5588256C1DD6AA464919C5" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------BA5588256C1DD6AA464919C5 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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. 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. To answer why I want this data: I want to be able to identify queries which are consuming large amounts of CPU time so that I can either optimize the query or optimize the application making the query, and free up CPU resources on the database. The `pg_stat_statements` view provides the `total_time` metric, but many things can contribute to query time other than CPU usage, and CPU usage is my primary concern at the moment. Do these seem like reasonable requests? And if so, what's the procedure for getting them implemented? Any thoughts on whether they would be hard to implement? I'm unfamiliar with the PostgresQL code base, but might be willing to attempt an implementation if it wouldn't be terribly difficult. -Patrick --------------BA5588256C1DD6AA464919C5 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit 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.
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.

To answer why I want this data: I want to be able to identify queries which are consuming large amounts of CPU time so that I can either optimize the query or optimize the application making the query, and free up CPU resources on the database. The `pg_stat_statements` view provides the `total_time` metric, but many things can contribute to query time other than CPU usage, and CPU usage is my primary concern at the moment.

Do these seem like reasonable requests? And if so, what's the procedure for getting them implemented?
Any thoughts on whether they would be hard to implement? I'm unfamiliar with the PostgresQL code base, but might be willing to attempt an implementation if it wouldn't be terribly difficult.

-Patrick
--------------BA5588256C1DD6AA464919C5--