find long running query in postgres
✓ Published0🌍 Public
Aadkdev
Last edited Jan 15, 2019
Created on Jan 15, 2019
This example displays PostgreSQL processes that have been running for more than five minutes, highlighting long-running queries for database monitoring. It uses a SQL query against `pg_stat_activity` to retrieve process IDs, query text, waiting status, wait reasons, and start times, filtering out idle sessions and ordering by duration. The visualization presents these results as a text-based table or list, with the data sourced directly from the live database system catalog. The code relies on standard PostgreSQL system functions like `now()` and interval comparisons to identify and rank the most time-consuming queries.
AI-generated description