DROP_SUBSCRIPTION(7pg18)

๐Ÿ“ฆ version 18.6, in opensuse-leap 16.0

โœจ DROP_SUBSCRIPTION โœจ

okay bestie, welcome to the DROP_SUBSCRIPTION page of the PostgreSQL 18.6 Documentation ๐Ÿ’– this is the manual for yeeting a subscription and honestly it's giving "cleanup era" ๐Ÿ’…


๐Ÿฆ‹ NAME ๐Ÿฆ‹

DROP_SUBSCRIPTION โ€” remove a subscription ๐Ÿ—‘๏ธโœจ


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

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

that's it, that's the whole vibe check ๐Ÿซถ


๐Ÿ’œ DESCRIPTION ๐Ÿ’œ

So DROP_SUBSCRIPTION removes a subscription from the database cluster. bye girl ๐Ÿ‘‹๐Ÿ’€

To actually run this command, you must be the owner of the subscription. no borrowing, no sneaking in, it's yours or it's not happening ๐Ÿ’…

๐Ÿšจ Important: 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 โ€” more on that below bestie ๐Ÿซถ)

๐ŸŒธ PARAMETERS ๐ŸŒธ

  • IF EXISTS โ€” do not throw an error if the subscription does not exist. A notice is issued in this case. so like, no dramatic meltdown if it's already gone ๐Ÿ™ˆโœจ
  • name โ€” the name of a subscription to be dropped. literally just tell it which one, bestie ๐ŸŽฏ
  • CASCADE and RESTRICT โ€” these key words do not have any effect, since there are no dependencies on subscriptions. iconic behaviour honestly, they just sit there looking pretty ๐Ÿ‘‘ no cap, zero effect fr fr.

๐Ÿ”ฅ NOTES ๐Ÿ”ฅ

okay this is the part you actually need to read, don't scroll past it ๐Ÿ’–

When you drop a subscription that's 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. it's giving "responsible adult" energy, we love to see it ๐Ÿซถ

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. ๐Ÿ˜ญ

To proceed in this situation, do this lil two-step:

  1. first disable the subscription by executing ALTER SUBSCRIPTION ... DISABLE
  2. 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. bestie. BESTIE. do not let your disk fill up. that is not the vibe. ๐Ÿ˜ญ๐Ÿ”ฅ

See also Section 29.2.1. ๐Ÿ“–

And one more time for the people in the back:

๐Ÿšจ If a subscription is associated with a replication slot, then DROP_SUBSCRIPTION cannot be executed inside a transaction block. periodt. ๐Ÿ’…

๐ŸŒˆ EXAMPLES ๐ŸŒˆ

Drop a subscription:

DROP SUBSCRIPTION mysub;

slay, gone, deleted, no more, we stan a clean exit โœจ


๐Ÿ’ซ COMPATIBILITY ๐Ÿ’ซ

DROP_SUBSCRIPTION is a PostgreSQL extension. it's our thing, iykyk ๐Ÿ’…


๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘


and that's the whole page!! mwah ๐Ÿ’‹ this was the DROP_SUBSCRIPTION(7) man page from PostgreSQL 18.6, dated 2026. go forth and drop responsibly bestie, and remember: the replication slot does NOT drop itself ๐ŸŒธ๐Ÿฆ‹๐Ÿ’–

๐Ÿ“ฆ where this page comes from