Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgresql Check if query is still running

At my work, I needed to build a new join table in a postgresql database that involved doing a lot of computations on two existing tables. The process was supposed to take a long time so I set it up to run over the weekend before I left on Friday. Now, I want to check to see if the query finished or not.

How can I check if an INSERT command has finished yet while not being at the computer I ran it on? (No, I don't know how many rows it was suppose to add.)

like image 547
Thomas Avatar asked Feb 28 '16 17:02

Thomas


1 Answers

Select * from pg_stat_activity where state not ilike 'idle%' and query ilike 'insert%'

This will return all non-idle sessions where the query begins with insert, if your query does not show in this list then it is no longer running.

pg_stat_activity doc

like image 55
jkdba Avatar answered Oct 07 '22 01:10

jkdba