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.
- Login to the PostgresSQL command-line interface
- Run the following query:
psql -U [username] [database_name]
SELECT datname,usename,procpid,client_addr,waiting,query_start,current_query FROM pg_stat_activity;
I want to ask how to know what’s query if the idle status