Can I get results from a Postgres query that I got disconnected from?

Posted on

Question :

I started an hours-long Postgres query in my psql shell. Then, I got disconnected from the network and had to make a new psql shell. If I look in pg_stat_activity, I see that my query is still running. Can I connect to that query and get its output?

Answer :

Unfortunately you can’t. However, if the query is for changing data and there isn’t any transaction started, then it will make the change. Next time start a screen or save results to a file.

No. If the process is long use intermediate tables + screen.

Leave a Reply

Your email address will not be published. Required fields are marked *