patternsqlMinor
check history along with dates for queries in Postgres
Viewed 0 times
postgreshistorywithqueriesdatesforalongcheck
Problem
I am running
Below gives us only the last query executed
but looks like this
and if we do save output to a filename where does it gets stored on
Kindly suggest if there are more specific way, actually I am looking for the queries executed on particular date.
PostgreSQL on my Linux terminal and If we do select pg_backend_pid(); it gives pid for specific session.Below gives us only the last query executed
select pid,
usename as username,
datname as database_name,
query,
application_name,
backend_start,
state,
state_change
from pg_stat_activity
where pid = 'your-pid';but looks like this
\s gives us all the history of query but not with dates. can we get dates along with themand if we do save output to a filename where does it gets stored on
Linux server?\s filenameKindly suggest if there are more specific way, actually I am looking for the queries executed on particular date.
Solution
PostgreSQL doesn't remember the times when queries are run.
If you need that information, set
If you need that information, set
log_statement = 'all' and include %m in log_line_prefix. Then the queries and their time are written to the log file.Context
StackExchange Database Administrators Q#280464, answer score: 5
Revisions (0)
No revisions yet.