agora inbox for pgsql-admin@postgresql.org  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Holger Jakobs <holger@jakobs.com>
Cc: pgsql-admin@lists.postgresql.org
Subject: Re: query execution time for last 24 hours in PostgreSQL
Date: Thu, 23 May 2024 15:26:18 -0400
Message-ID: <463820.1716492378@sss.pgh.pa.us> (raw)
In-Reply-To: <d2f858b4-6699-649a-0c0a-ac0038c25d56@jakobs.com>
References: <CACJRp483AWu5Jar4xt9y2wbdDq9Fsxqou6kaPLCs_ifC==902A@mail.gmail.com>
	<d2f858b4-6699-649a-0c0a-ac0038c25d56@jakobs.com>

Holger Jakobs <holger@jakobs.com> writes:
> Am 23.05.24 um 20:07 schrieb nikhil kumar:
>> Can you please let me know anyone how to get each query execution time 
>> from last 24 hours in PostgreSQL

> pg_stat_activity shows current activity, not historic activity.
> Unless you use an extension like pg_stat_statements, or log your 
> statements, the information won't be available.

pg_stat_statements only collects cumulative runtime.  The OP seems
to be asking for the runtime of each execution of each statement.
The only way to get that is by logging the durations (see log_duration
and related settings) and then scraping the postmaster log.  You
might want to use pgbadger or a similar tool to help with the scraping
and subsequent data analysis.

			regards, tom lane





view thread (4+ messages)

Message-ID: <463820.1716492378@sss.pgh.pa.us>
Permalink:  ../463820.1716492378@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/463820.1716492378@sss.pgh.pa.us

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, holger@jakobs.com, pgsql-admin@lists.postgresql.org
  Subject: Re: query execution time for last 24 hours in PostgreSQL
  In-Reply-To: <463820.1716492378@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox