<img height="1" width="1" style="display:none;" alt="" src="https://px.ads.linkedin.com/collect/?pid=2826169&amp;fmt=gif">
Start  trial

    Start trial

      Tired of constantly running checks on your PostgreSQL activity as it happens? Save time and energy with \watch.

      I quite often get asked to have a look at what’s happening in a PostgreSQL database. So I'll execute something like “SELECT * FROM pg_stat_activity;” once every minute or so to get a quick feel of what’s going on. This will display a list of the current connections to the database along with various other bits of useful information that I use to get an idea of what’s going on in there.

      Then I discovered \watch.

      With \watch, I can issue the same query appended like this: “SELECT * FROM pg_stat_activity; \watch”, to  simply repeat the associated SQL statement once every two seconds. Now I can sit back and watch what’s happening without having to keep reissuing the command manually.

      This leaves me more time to look at other things without having to keep bringing the terminal to the foreground, reissue the SQL command, note the values, and then go back to another task.

      Every two seconds may be good for this query, or it may be overkill for other queries. No problem. That's why \watch has a delay value you can add like “\watch 60”, which repeats the SQL command every 60 seconds.

      If you are interested in learning more about \watch and how it may improve your PostgreSQL database, please contact us directly. Fujitsu provides 24/7 Australian-based PostgreSQL support and services, DBA and developer training, and our own enhanced version of PostgreSQL - Fujitsu Enterprise Postgres.

       

      Receive our blog

      Search by topic

      see all >

      Read our latest blogs

      Read our most recent articles regarding all aspects of PostgreSQL and Fujitsu Enterprise Postgres.

      Receive our blog

      Fill the form to receive notifications of future posts

      Search by topic

      see all >