MySQL has a very powerfull command through “show full processlist;”, to see a list of currently running queries.
# mysql
# mysql > show full processlist;
PostgreSQL has a similar shell to MySQL, named psql . Here’s how it works. First, change to the postgres user.
# su postgres
Enter the PostgreSQL command shell.
# [postgres@srv]$ psql
And perform the query to see the current activity.
postgres=# select * from pg_stat_activity;
To quit the PostgreSQL shell, type "\q".
This requires you have PostgreSQL configured to track activity. On modern PostgreSQL versions this is on by default. If it isn’t, make sure the following line is set in your config (this was called stats_command_string before PostgreSQL 8.3). Edit your config file (usually at /usr/local/pgsql/data/postgresql.conf) and set it explicitly.
track_activities = on
And reload your PostgreSQL.
pg_ctl reload