performance statistics monitoring without spamming logs

From: Patrick Hemmer <postgresql(at)stormcloud9(dot)net>
To: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: performance statistics monitoring without spamming logs
Date: 2018-07-10 17:54:12
Message-ID: 7ffb9dbe-c76f-8ca3-12ee-7914ede872e6@stormcloud9.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-performance

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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2018-07-10 18:05:55 Re: no partition pruning when partitioning using array type
Previous Message Alvaro Herrera 2018-07-10 17:51:29 Re: _isnan() on Windows

Browse pgsql-performance by date

  From Date Subject
Next Message Justin Pryzby 2018-07-10 18:38:28 Re: performance statistics monitoring without spamming logs
Previous Message Lincoln Swaine-Moore 2018-07-10 15:07:42 Improving Performance of Query ~ Filter by A, Sort by B