How to show what is running in postgres?

Edit your postgres.conf and add or change this:

stats_start_collector = true (true for the statistics collector)

stats_command_string = true (It enables monitoring of the current command being executed by any server process.The statistics collector subprocess need not be running to enable this feature.)

Restart postgres:

/etc/init.d/postgresql restart

the following query will show currently running queries:

psql -U postgres template1 -c “select * from pg_stat_activity” (only as user “postgres”)

Or in pgadmin:

select * from pg_stat_activity

Discussion Area - Leave a Comment