postgres=# select * from sessions where video_id = 'vTV8XhWf3mo';
Postgres Hacking 101: \watch with limited loops
Add a maximum iteration count to psql \watch.
session summary
The main exercise added a maximum iteration count to psql's backslash-watch command, allowing monitoring or sampling queries to stop automatically. Parsing a second optional argument exposed subtleties in psql's meta-command scanner, whitespace handling, defaults, and preserving unlimited behavior; the live prototype was close but still malfunctioned and needed offline cleanup before its later upstream completion. The final segment reviewed a proposed pg_stat_session view, questioning its per-backend memory and runtime overhead, missing functional tests, and practical value to DBAs.
timecodes
- Use case for a bounded psql watch
- ULID work shifts toward UUIDv7
- Starting the psql meta-command patch
- Tracing watch argument parsing
- Adding the optional iteration argument
- Learning how multi-argument meta-commands parse
- Iteration defaults and preserving infinity
- Reviewing pg_stat_session counters and overhead