HeatWare.net header image
HeatWare.net
TwitterRSSEmail
  • Home
  • Windows
    • Windows 8
    • Windows 7
    • Windows Vista
    • Windows XP
  • Linux/Unix
  • Mac
  • Mobile
    • Android
    • iOS
    • Phones (Help / Resources)
  • Software / Programming
    • Free Software
    • Programming – General
    • PHP
    • Ruby/Rails
    • Quality Assurance (QA)
    • Software – General
    • Software Help
    • Databases
  • Cool Websites
  • Other
    • Deals & Bargains
    • News
    • Video Games
    • Hardware
    • Electronics
  • About

5 comments / August 22, 2010 / sood / Databases

How to see active SQL queries and open connections in Postgres?

This article will show you how to see a list of open database connections as well as all active queries that are running on a PostgresSQL 8.x database. This information can be very beneficial when profiling your application and determining queries that have “gone wild” and are eating CPU cycles.

  1. Login to the PostgresSQL command-line interface
  2. psql -U [username] [database_name]

  3. Run the following query:
  4. SELECT datname,usename,procpid,client_addr,waiting,query_start,current_query FROM pg_stat_activity;

Related Posts

  • Find PostgreSQL database size using SQL 'Select'
  • How to find (log) slow queries in PostgreSQL 8.x, 9.x
  • How to view table/row locks in Postgres?
  • pgAdmin - PostgreSQL GUI Management Tool
  • How to install PostgreSQL 8.4 on CentOS 5.5

Databases PostgreSQL

5 comments… add one
  1. didik May 2, 2011, 3:54 am

    I want to ask how to know what’s query if the idle status

  2. Sebastian April 28, 2014, 6:21 am

    Hi!

    The Query does not work for newer Versions of PostgreSQL. ‘procpid’ was renamed to ‘pid’ and ‘current_query’ is ‘query’ now. So:
    SELECT datname,usename,pid,client_addr,waiting,query_start,query FROM pg_stat_activity;

    Sebastian

  3. amit June 13, 2014, 4:32 am

    How about select query from pg_stat_activity;

  4. Mohanraj May 25, 2015, 3:59 am

    “\c” is not working in windows – psql

    How to clear that error…….?

    ERROR: syntax error at or near “\”
    LINE 3: \c busservice
    ^
    ********** Error **********

    ERROR: syntax error at or near “\”
    SQL state: 42601
    Character: 67

  5. Kes November 5, 2018, 10:26 am

    postgres=# SELECT datname,usename,procpid,client_addr,waiting,query_start,current_query FROM pg_stat_activity;
    ERROR: column “procpid” does not exist

    ???

Cancel reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • Why You Should Consider Diving Apps
  • How to Buy a Smartphone that Fits Your Budget
  • How to Overcome Frustrating PDF Stress
  • Convert PDF to Word: Easy, Reliable and Quality Conversion
  • PDF to Excel App ­ – A New Way of Handling Tricky Documents

Recent Comments

  • Valarie Walter on Basic Troubleshooting Steps for your Cell Phone
  • John Mists on A Brief History of Android OS
  • syarif on PostgreSQL: How to reload config settings without restarting database
  • Raghu on How to SSH to a server using Ruby – Part I
  • francisco clemente on Basic Troubleshooting Steps for your Cell Phone

Tags

ACSLS Android Bargain Cell Phones Cool Software Cool Websites Databases Deals Ebooks Facebook Free Software G2x Galaxy S5 iOS iPhone Kindle LG Linux Linux/Unix Mac Mobile mysql Office OpenStack OS X PHP Postgres PostgreSQL ruby Samsung Galaxy S6 Shell Smartphones Sun T-Mobile Tips Tips & Tricks Ubuntu Unix Virtualization VMWare Windows Windows 7 Windows 8 Windows Vista Windows XP

Latest Tweet

Follow @HeatwaredotNet

SP
@HeatwaredotNet

  • Why You Should Consider Diving Apps https://t.co/Is41cdUv2I #diving-apps
    about 6 years ago

All Categories

Other Links

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Copyright © 2015 — HeatWare