UNLISTEN(7)

πŸ“¦ version 14.24, in opensuse-leap 16.0

πŸ’… 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 how LISTEN and NOTIFY actually work together, NOTIFY(7) has a more extensive discussion of the use of LISTEN and NOTIFY. 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 UNLISTEN something 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 UNLISTEN cannot 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