UNLISTEN(7)

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

πŸ’… UNLISTEN(7) β€” stop listening, bestie πŸ’…

okay so this is the PostgreSQL 15.19 Documentation page for UNLISTEN, and it's lowkey the unsubscribe button for notification registrations. no cap, it's giving β€œclean up your listener registration” energy. 🫢

✨ NAME ✨

UNLISTEN β€” stop listening for a notification. literally the β€œcancel my subscription” of the notification world πŸ’…

πŸ¦‹ SYNOPSIS πŸ¦‹

UNLISTEN { channel | * }

🌸 DESCRIPTION 🌸

UNLISTEN is used to remove 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. The special wildcard * cancels all listener registrations for the current session. πŸŽ€

NOTIFY(7) contains a more extensive discussion of the use of LISTEN and NOTIFY. iykyk, go read that one too πŸ’–

πŸŽ€ PARAMETERS πŸŽ€

  • channel β€” name of a notification channel (any identifier).
  • * β€” all current listen registrations for this session are cleared. periodt.

πŸ”₯ NOTES πŸ”₯

  • You can unlisten something you were not listening for; no warning or error will appear. not me unsubscribing from a channel I never joined 😭
  • At the end of each session, UNLISTEN * is automatically executed. the cleanup is automatic, bestie.
  • A transaction that has executed UNLISTEN cannot be prepared for two-phase commit. highkey important caveat, so remember it.

πŸ“ EXAMPLES πŸ“

To make a registration:

LISTEN virtual;
NOTIFY virtual;
Asynchronous notification "virtual" received from server process with PID 8448.

Once UNLISTEN has been executed, further NOTIFY messages will be ignored:

UNLISTEN virtual;
NOTIFY virtual;
-- no NOTIFY event is received

🌈 COMPATIBILITY 🌈

There is no UNLISTEN command in the SQL standard. so yeah, it’s giving not-in-the-standard energy, bestie πŸ’…

πŸ‘‘ SEE ALSO πŸ‘‘

LISTEN(7), NOTIFY(7)


mwah πŸ’– β€” this iconic little page is from PostgreSQL 15.19, dated 2026, and it's literally called UNLISTEN(7). bye bestie 🫢

πŸ“¦ where this page comes from