UNLISTEN(7)
π UNLISTEN(7) β the postgres manual, but make it group chat
ok so real quick β this is the UNLISTEN page from the PostgreSQL 13.23 documentation, and we're about to make it make sense. no cap. π«Ά
β¨ NAME β¨
UNLISTEN β stop listening for a notification π€
πΈ SYNOPSIS πΈ
UNLISTEN { channel | * }
π¦ DESCRIPTION π¦
k so bestie, UNLISTEN is literally how you remove a registration you already made for NOTIFY events. it cancels any existing registration of the current PostgreSQL session as a listener on the notification channel named channel. like, you're unsubscribing. self-care honestly. π
and then there's the special wildcard * β that one cancels all listener registrations for the current session. every single one. it's giving mass-unfollow. π₯
if you want the whole extensive discussion of how LISTEN and NOTIFY work together, that lives in NOTIFY(7). go read it. iykyk. π
π PARAMETERS π
channelβ name of a notification channel (any identifier). literally any identifier, she's flexible. β¨*β all current listen registrations for this session are cleared. all of them. gone. π
π NOTES π
bestie listen β you can UNLISTEN something you were never listening for. no warning. no error. it justβ¦ happens. the server does not care and will not tell you. π
at the end of each session, UNLISTEN * is automatically executed. so your session cleans up after itself whether you like it or not. π§
β οΈ a transaction that has executed UNLISTEN cannot be prepared for two-phase commit. like, that's just how it is. plan accordingly. π
π₯ EXAMPLES π₯
to make a registration, you do this:
LISTEN virtual;
NOTIFY virtual;
Asynchronous notification "virtual" received from server process with PID 8448.
and once UNLISTEN has been executed, further NOTIFY messages will be ignored. ignored!! she does not see them. π
UNLISTEN virtual;
NOTIFY virtual;
-- no NOTIFY event is received
π COMPATIBILITY π
there is no UNLISTEN command in the SQL standard. she's built different. a postgres original. π
β SEE ALSO β
and that's the whole page bestie π β brought to you by PostgreSQL 13.23, dated 2025, aka the UNLISTEN(7) era. go forth and stop listening to things. πβ¨π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms