Sometimes it happens that you must do everything only in terminal from command line. So here are some useful commands:
- List of database sessions and queries from pg_stat_activity every 2 seconds with highlighting differences:
watch -d -n 2 'psql -U upcload -d queries -c "select datname, pid, usename, client_addr, query_start, waiting, state, substr(query,1,80) from pg_stat_activity order by state" '
- List of postgres processes refreshed every 1 second with highlighting differences:
watch -d -n 1 'ps -ef|grep postgres'