7 Jun 2010, 13:24

Comments Off

Tips&Tricks: Get long running queries from PostgreSQL

Was looking for a method of getting queries that are running longer than 5 minutes out of a PostgreSQL. This solution needs stats_command_string enabled in the postgresql.conf, though. The query you can run:

echo "select procpid,datname,current_query,now() - pg_stat_activity.query_start as duration from pg_stat_activity where pg_stat_activity.current_query <> ''::text and now() - pg_stat_activity.query_start > interval '5 minutes'" | sudo -u postgres psql

Hope this helps someone!

 
  • Calender

    June 2010
    M T W T F S S
    « Apr   Jul »
     123456
    78910111213
    14151617181920
    21222324252627
    282930  
  • Twitter

    Powered by Twitter Tools

  • RSS Delicious feed

  • Archives