Hi Team,
SELECT sa.client_addr,
sa.usename,
sa.datname,
sa.state,
sa.query,
sa.query_start,
EXTRACT (EPOCH FROM (current_timestamp sa.query_start)) AS execution_time_seconds
FROM pg_stat_activity sa
WHERE sa.query_start >= current_timestamp interval '24 hours';
Can you please let me know anyone how to get each query execution time from last 24 hours in PostgreSQL
I tried the below query but giving the wrong information.
SELECT sa.client_addr,
sa.usename,
sa.datname,
sa.state,
sa.query,
sa.query_start,
EXTRACT (EPOCH FROM (current_timestamp sa.query_start)) AS execution_time_seconds
FROM pg_stat_activity sa
WHERE sa.query_start >= current_timestamp interval '24 hours';
Thanks,
Nikhil,
PostgreSQL DBA,
8074430856.