↑↓ select ↵ open ⌫ change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Wiki / psql Commands / Query execution

\watch

Repeatedly execute the current query buffer (as \g does) until interrupted, or the query fails, or the execution count limit (if given) is reached, or the query no longer returns the minimum number of rows. Wait the specified number of seconds (defa…

Reading PostgreSQL 18.6.

Description

Repeatedly execute the current query buffer (as \g does) until interrupted, or the query fails, or the execution count limit (if given) is reached, or the query no longer returns the minimum number of rows. Wait the specified number of seconds (default 2) between executions. The default wait can be changed with the variable WATCH_INTERVAL . For backwards compatibility, seconds can be specified with or without an interval= prefix. Each query result is displayed with a header that includes the \pset title string (if any), the time as of query start, and the delay interval.

Client
psql 18.6
Case-sensitive spelling
\watch

Usage

\watch [ i[nterval]= seconds ] [ c[ount]= times ] [ m[in_rows]= rows ] [ seconds ]

Spellings in this manual definition

CommandDocumented suffix modifiers
\watchNone listed in this signature

Manual definition

\watch [ i[nterval]=seconds ] [ c[ount]=times ] [ m[in_rows]=rows ] [ seconds ]

Repeatedly execute the current query buffer (as \g does) until interrupted, or the query fails, or the execution count limit (if given) is reached, or the query no longer returns the minimum number of rows. Wait the specified number of seconds (default 2) between executions. The default wait can be changed with the variable WATCH_INTERVAL. For backwards compatibility, seconds can be specified with or without an interval= prefix. Each query result is displayed with a header that includes the \pset title string (if any), the time as of query start, and the delay interval.

If the current query buffer is empty, the most recently sent query is re-executed instead.

Related entries

Documentation and source

Source build
Version
18.6
Build
https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2
Source fingerprint
ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8

Compare versions

PostgreSQL 15 → 16: changed.

--- PostgreSQL 15
+++ PostgreSQL 16
@@ -1,7 +1,7 @@
 {
-  "definition": "Repeatedly execute the current query buffer (as \\g does) until interrupted or the query fails. Wait the specified number of seconds (default 2) between executions. Each query result is displayed with a header that includes the \\pset title string (if any), the time as of query start, and the delay interval. If the current query buffer is empty, the most recently sent query is re-executed instead.",
+  "definition": "Repeatedly execute the current query buffer (as \\g does) until interrupted, or the query fails, or the execution count limit (if given) is reached. Wait the specified number of seconds (default 2) between executions. For backwards compatibility, seconds can be specified with or without an interval= prefix. Each query result is displayed with a header that includes the \\pset title string (if any), the time as of query start, and the delay interval. If the current query buffer is empty, the most recently sent query is re-executed instead.",
   "modifiers": [],
-  "signature": "\\watch [ seconds ]",
+  "signature": "\\watch [ i[nterval]= seconds ] [ c[ount]= times ] [ seconds ]",
   "spellings": [
     "\\watch"
   ]

Compares recorded interfaces and attributes. Source fingerprints and build metadata are excluded; an absent sample is not proof of the introduction or removal release.

Related entries

Export JSON · Back to psql Commands · Recorded in PostgreSQL 10 through 20; the first sample is not necessarily its introduction.