tcn
A contrib module which generates NOTIFY events on table changes
tcn
("triggered change notification") is a contrib module implemented as an extension which generates NOTIFY events on table changes via a trigger function.
tcn
was added in PostgreSQL 9.2.
Use cases
tcn
is useful for applications using drivers which support asynchronous notification: this makes it possible to notify all clients if the contents of a table have been changed, enabling them to take appropriate action in near-real time, such as updating a table cache or information display.
Implementation
tcn
provides a single function, triggered_change_notification()
, to be added as a row-level trigger.
Change history
With the exception of bugfixes and minor code changes, tcn
has remained unchanged since it was added in PostgreSQL 9.2.
- PostgreSQL 13
- marked as a
trusted extension
(commit eb67623c)
- marked as a
- PostgreSQL 9.2 (1.0)
- added (commit 6e3323d4)
References
- PostgreSQL documentation: tcn
Useful links
- Module Monday: tcn - overview and example
- tcn again - sample implementation of cache updates in Python