Killing processes and PostgreSQL Queries

I’ve been working on issues related to processes and PostgreSQL these past few days. Minor as they were, I think these are common issues that aren’t documented very well. I recently had a problem canceling queries issued from PGAdmin. I decided to cancel the queries by looking up the process id and canceling the process thats running the query.

You can look up the process id, or the ‘pid’ column, by executing the following query in psql or PGAdmin:

select * from pg_stat_activity;

This query will return a list of all processes currently being run by your server. After finding the query you want to cancel, go to the BASH prompt and type:

sudo kill pid_number

Another problem that I ran into the other day was figuring out which processes a java server was running on. I did this by querying processes by name or browsing through all of the server’s processes. To query processes by a name, I typed:

ps -o user,pid,ppid,command -ax | grep java

If you still can’t find the process, you can browse all processes by typing:


New Article

Leave a Reply