DROP_SUBSCRIPTION(7pg13)
π DROP_SUBSCRIPTION β bestie's guide to yeeting a subscription β¨
okay so real talk, this is the DROP_SUBSCRIPTION page from the PostgreSQL 13.23 docs, and it's literally about removing a subscription from the database cluster. iconic, lowkey destructive, we love a clean exit π
β¨ SYNOPSIS β¨
DROP SUBSCRIPTION [ IF EXISTS ] name [ CASCADE | RESTRICT ]
that's it. that's the whole vibe check π¦
π DESCRIPTION π
DROP SUBSCRIPTION removes a subscription from the database cluster. bye bestie π
not everyone can do this, though β a subscription can only be dropped by a superuser. so if you're not one, this is not your main character moment, sorry π
also, important: DROP SUBSCRIPTION cannot be executed inside a transaction block if the subscription is associated with a replication slot. ngl that's a whole thing. (good news though β you can use ALTER SUBSCRIPTION to unset the slot.) π
πΈ PARAMETERS πΈ
nameβ the name of the subscription you're dropping. the one getting yeeted. πCASCADE,RESTRICTβ okay so these key words literally do not have any effect, because there are no dependencies on subscriptions. they're just... there. decorative. furniture. ποΈβ¨
π§ NOTES π§
okay this part is the important one, pay attention π
when you drop a subscription that's associated with a replication slot on the remote host (which is the normal state, iykyk), DROP SUBSCRIPTION will connect to the remote host and try to drop the replication slot as part of its operation. why? because the resources allocated for the subscription on the remote host need to be released. slay, responsible queen π₯
but here's the catch β if that fails, DROP SUBSCRIPTION will fail too. and it can fail for a few reasons:
- the remote host is not reachable π
- the remote replication slot cannot be dropped
- the remote replication slot does not exist
- the remote replication slot never existed
to proceed in this situation, first disable the subscription by executingALTER SUBSCRIPTION ... DISABLE, and then disassociate it from the replication slot by executingALTER SUBSCRIPTION ... SET (slot_name = NONE). after that,DROP SUBSCRIPTIONwill no longer attempt any actions on a remote host. π«Ά
and β huge caveat, do not skip this β note that if the remote replication slot still exists, it should then be dropped manually; otherwise it will continue to reserve WAL and might eventually cause the disk to fill up. like, disk full. the worst kind of plot twist π see also Section 30.2.1.
also, 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. β
π EXAMPLES π
drop a subscription, simple as:
DROP SUBSCRIPTION mysub;
and that's the whole flex β¨
π COMPATIBILITY π
DROP SUBSCRIPTION is a PostgreSQL extension. not standard SQL, it's our thing π
π SEE ALSO π
CREATE SUBSCRIPTION(CREATE_SUBSCRIPTION(7))ALTER SUBSCRIPTION(ALTER_SUBSCRIPTION(7))
and that's the page!! go forth and drop responsibly, bestie π¦π
PostgreSQL 13.23 Β· 2025 Β· DROP SUBSCRIPTION(7) β mwah, love u, see u in the next manpage π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms