Show running queries on Postgresql/Greenplum

I've got some queries that run for a long time. Sometimes longer than others. I wanted to see how long active queries have been running. Here's a view to consistently do that:

CREATE VIEW public.view_activequeries AS ( SELECT age(query_start, backend_start) AS queryage,* FROM pg_stat_activity WHERE current_query NOT LIKE '%IDLE%' ORDER BY queryage DESC);

Then you just run:

select * from public.view_activequeries;

You get a list of all active queries in descending order of how long they have been running, i.e. longest running queries listed first.

Comments

Post a Comment

Popular posts from this blog

Database, schema, and table sizes in Greenplum

Greenplum update with multiple tables