watch for database changes on postgresql

March 9, 2016   

If you are tyring to debug multi-threaded environments or a really fast job queue you might need to “watch” a table for changes.

In psql use the \watch command like so:

\watch 1 "select * from job_queue";

This will run the query every 1 second (you can change the second argument if you need it slower) and display the result as well as past results.

About the Author
Responsive image

I'm Dorian Karter, a Full Stack Software Consultant.

I work at Hashrocket, a top web development consultancy based in Chicago.

Have a look at some of my open source projects.

Contact me at @dorian_escplan.