DROP_SUBSCRIPTION(7pg16)

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

πŸ’– NAME β€” DROP_SUBSCRIPTION(7pg16): remove a subscription

okay so bestie, this is the PostgreSQL 16.15 documentation, and the page is literally DROP SUBSCRIPTION(7) β€” yes, that's the manual name, and the slug is DROP_SUBSCRIPTION(7pg16). it's giving "short command, big remote-slot feelings." 🫢


✨ SYNOPSIS ✨

DROP SUBSCRIPTION [ IF EXISTS ] name [ CASCADE | RESTRICT ]

πŸ’… DESCRIPTION πŸ’…

DROP SUBSCRIPTION removes a subscription from the database cluster. iconic. no cap. 🌸

To execute this command, the user must be the owner of the subscription. owner energy only, bestie. πŸ‘‘

DROP SUBSCRIPTION cannot be executed inside a transaction block if the subscription is associated with a replication slot. (You can use ALTER SUBSCRIPTION to unset the slot.) lowkey important, write it down. 😭

πŸŽ€ PARAMETERS πŸŽ€

  • IF EXISTS β€” do not throw an error if the subscription does not exist. a notice is issued in this case. so it's like "bestie, she's not here" but polite. πŸ“
  • name β€” the name of a subscription to be dropped. literally the subscription's name, no mystery. πŸ’…
  • CASCADE, RESTRICT β€” these key words do not have any effect, since there are no dependencies on subscriptions. they're just standing there, serving nothing, and honestly that's iconic. πŸ§β€β™€οΈ

πŸ¦‹ NOTES πŸ¦‹

When dropping a subscription that is associated with a replication slot on the remote host (the normal state), DROP SUBSCRIPTION will connect to the remote host and try to drop the replication slot (and any remaining table synchronization slots) as part of its operation. This is necessary so that the resources allocated for the subscription on the remote host are released. 🌈

If this fails, either because the remote host is not reachable or because the remote replication slot cannot be dropped or does not exist or never existed, the DROP SUBSCRIPTION command will fail. yes, all of those flavors of fail. πŸ’€

To proceed in this situation, first disable the subscription by executing:

ALTER SUBSCRIPTION ... DISABLE

and then disassociate it from the replication slot by executing:

ALTER SUBSCRIPTION ... SET (slot_name = NONE)

After that, DROP SUBSCRIPTION will not attempt to drop the subscription's own replication slot. It may still connect to the publisher to drop internally-created table synchronization slots if some table synchronization is left unfinished; if the publisher is unreachable, those slots (and the main slot, if it still exists) must be dropped manually. Otherwise it/they will continue to reserve WAL and might eventually cause the disk to fill up. 🚨 this is the "your disk is not okay" part.

See also Section 31.2.1. πŸ“–

If a subscription is associated with a replication slot, then DROP SUBSCRIPTION cannot be executed inside a transaction block. yes, this caveat said it twice because it matters. periodt. πŸ’…

🌸 EXAMPLES 🌸

Drop a subscription:

DROP SUBSCRIPTION mysub;

ate. πŸ’…

πŸ”₯ COMPATIBILITY πŸ”₯

DROP SUBSCRIPTION is a PostgreSQL extension. iykyk. ✨

🫢 SEE ALSO 🫢


okay bestie, that's the whole page. stay hydrated, keep your replication slots close, and remember this is PostgreSQL 16.15 documentation, dated 2026. mwah πŸ’‹

πŸ“¦ where this page comes from