UNLISTEN(7)
π UNLISTEN(7) β the PostgreSQL manual, but make it group chat
okay so bestie, quick vibe check: this is the UNLISTEN page from the PostgreSQL 14.24 docs, and it's honestly shorter than my attention span, so let's get into it π
β¨ NAME β¨
UNLISTEN β stop listening for a notification. that's it. that's the whole name. it's giving "unsubscribe" energy π
π¦ SYNOPSIS π¦
UNLISTEN { channel | * }
literally two choices: name a channel, or hit it with the wildcard *. no cap.
πΈ DESCRIPTION πΈ
so UNLISTEN is the icon that removes an existing registration for NOTIFY events π. it cancels any existing registration of the current PostgreSQL session as a listener on the notification channel named channel β key word current session, iykyk.
and the special wildcard *? that cancels all listener registrations for the current session. one * and everything's gone, main character energy fr fr π
if you want the full deep-dive tea on howLISTENandNOTIFYactually work together,NOTIFY(7)has a more extensive discussion of the use ofLISTENandNOTIFY. go read it, bestie π«Ά
π PARAMETERS π
- channel β the name of a notification channel. and yes, it can be any identifier, so live your truth.
*β all current listen registrations for this session are cleared. all of them. periodt π
π₯ NOTES π₯
- ngl, you can
UNLISTENsomething you were never listening for, and literally nothing happens β no warning, no error. it justβ¦ vibes. π - at the end of each session,
UNLISTEN *is automatically executed. the server cleans up after you, bestie, it's so caring π - a transaction that has executed
UNLISTENcannot be prepared for two-phase commit. that's a real caveat, not a drill β οΈ
β EXAMPLES β
first, to make a registration:
LISTEN virtual;
NOTIFY virtual;
Asynchronous notification "virtual" received from server process with PID 8448.
okay so that's you being a listener. now once UNLISTEN has been executed, further NOTIFY messages will be ignored:
UNLISTEN virtual;
NOTIFY virtual;
-- no NOTIFY event is received
see how the second one gets nothing? yeah. silence. iconic. π€«
π COMPATIBILITY π
there is no UNLISTEN command in the SQL standard. we're built different, we're off-script, we're the moment π
π SEE ALSO π
the holy trinity honestly π«Ά
and that's the whole page, bestie β no notes, ate and left no crumbs π
signed, sealed, delivered by the PostgreSQL 14.24 docs, dated 2026, on the UNLISTEN(7) page itself π§π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-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