UNLISTEN(7)
โจ UNLISTEN โจ
ok so bestie, this is the PostgreSQL 18.6 page for UNLISTEN ๐ it's giving "quiet quitting, but for notifications" and honestly? iconic.
๐ธ NAME ๐ธ
UNLISTEN โ stop listening for a notification ๐
like. you were on the notification grind and now you're simply. not. doing that anymore. no cap.
๐ SYNOPSIS ๐
UNLISTEN { channel | * }
that's it. that's the whole vibe. two options and one of them is a wildcard. slay.
๐ DESCRIPTION ๐
okay so UNLISTEN is what you use to remove an existing registration for NOTIFY events. basically you're unsubscribing. you're hitting that little bell icon and turning it OFF ๐
more specifically: UNLISTEN cancels any existing registration of the current PostgreSQL session as a listener on the notification channel named channel. so if this session was all "yes bestie, tell me everything about this channel," it's now "actually no, we're done here."
and then there's the special wildcard * ๐ฆ which cancels all listener registrations for the current session. every single one. a full clear-out. main character energy, honestly.
if you want the full deep lore on how LISTEN and NOTIFY actually work together, NOTIFY(7) has a way more extensive discussion. go read it, it's a whole thing ๐
๐ PARAMETERS ๐
channelโ the name of a notification channel. it can be any identifier. literally any one. pick your fave โจ*โ all current listen registrations for this session are cleared. all of them. every last one. the whole roster ๐
๐ซถ NOTES ๐ซถ
- you can unlisten something you were never listening for and nothing happens. no warning. no error. the database simply does not care. it's so unbothered fr fr ๐
- at the end of each session,
UNLISTEN *is automatically executed. so you don't even have to do it yourself. the cleanup is automatic. self-care is built in, bestie ๐ธ - a transaction that has executed
UNLISTENcannot be prepared for two-phase commit. that's just how it is. no workaround mentioned here, so don't come for me ๐ญ
๐ EXAMPLES ๐
to make a registration, you do this:
LISTEN virtual;
NOTIFY virtual;
Asynchronous notification "virtual" received from server process with PID 8448.
see? you listened, you got notified. beautiful. no notes ๐
once UNLISTEN has been executed, further NOTIFY messages will be ignored:
UNLISTEN virtual;
NOTIFY virtual;
-- no NOTIFY event is received
look at that. silence. peace. the notification simply never arrives. it's giving ghosted ๐
โญ COMPATIBILITY โญ
there is no UNLISTEN command in the SQL standard. this is a PostgreSQL exclusive. a little treat just for us ๐
๐ SEE ALSO ๐
that's the whole page!! ๐ this was PostgreSQL 18.6, documented in 2026, and you absolutely ate reading all of it. go forth and unsubscribe from your notifications, bestie ๐โจ๐ฆ
๐ฆ where this page comes from
- alpine 3.23: postgresql18-doc 18.6-r0 ยท PostgreSQL
- alpine 3.24: postgresql18-doc 18.6-r0 ยท PostgreSQL
- arch rolling: postgresql 18.6-4 ยท PostgreSQL
- fedora 43: postgresql 18.6-1.fc43 ยท PostgreSQL
- fedora 43: postgresql 18.6-1.fc43 ยท PostgreSQL
- fedora 44: postgresql 18.6-1.fc44 ยท PostgreSQL
- fedora 44: postgresql 18.6-1.fc44 ยท PostgreSQL
- nixos 26.05: postgresql 18.6
- ubuntu resolute: postgresql-client-18 18.6-0ubuntu0.26.04.1 ยท PostgreSQL
- ubuntu stonking: postgresql-client-18 18.6-3build2 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms