DROP_INDEX(7pg15)

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

πŸ’… DROP_INDEX πŸ’…

okay bestie so this is the DROP INDEX page from the PostgreSQL 15.19 docs and it's literally about yeeting an index out of your database ✨ it's giving cleanup era, it's giving "I'm done with this btree" πŸŽ€


✨ NAME ✨

DROP_INDEX β€” remove an index πŸ—‘οΈπŸ’–


🌸 SYNOPSIS 🌸

DROP INDEX [ CONCURRENTLY ] [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]

like look at her, so structured, so iconic πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

DROP INDEX drops an existing index from the database system, no cap. it just… removes it. gone. bye πŸ‘‹

but heads up: to run this command you must be the owner of the index. not your friend, not your mutuals β€” you, bestie. the owner. periodt πŸ’…


πŸ’– PARAMETERS πŸ’–

  • CONCURRENTLY β€” drop the index without locking out concurrent selects, inserts, updates, and deletes on the index's table πŸ₯³ because a normal DROP INDEX acquires an ACCESS EXCLUSIVE lock on the table, which blocks other accesses until the index drop can be completed. with this option, the command instead waits until conflicting transactions have completed. so polite. so patient. we stan 🫢
⚠️ okay so there are several caveats to be aware of when using this option, and you need to know them: - only one index name can be specified, and the CASCADE option is not supported. (thus, an index that supports a UNIQUE or PRIMARY KEY constraint cannot be dropped this way.) 😭 - also, regular DROP INDEX commands can be performed within a transaction block, but DROP INDEX CONCURRENTLY cannot. πŸ’€ - lastly, indexes on partitioned tables cannot be dropped using this option. nope. not happening. πŸ™ˆ for temporary tables, DROP INDEX is always non-concurrent, as no other session can access them, and non-concurrent index drop is cheaper. so like, don't even worry about it for temp tables πŸ’œ
  • IF EXISTS β€” do not throw an error if the index does not exist. a notice is issued in this case πŸŽ€ no drama, just a little "hey, that wasn't there" note. very chill. very demure.
  • name β€” the name (optionally schema-qualified) of an index to remove. that's your target bestie, go get her 🎯
  • CASCADE β€” automatically drop objects that depend on the index, and in turn all objects that depend on those objects (see Section 5.14). it's giving domino effect, it's giving chain reaction 🌈
  • RESTRICT β€” refuse to drop the index if any objects depend on it. and guess what, this is the default πŸ‘‘ so if you don't say anything, she's gonna be cautious about it.

⭐ EXAMPLES ⭐

this command will remove the index title_idx:

DROP INDEX title_idx;

and that's it. she's gone. slay πŸ’…βœ¨


πŸ”₯ COMPATIBILITY πŸ”₯

DROP INDEX is a PostgreSQL language extension πŸ¦‹ there are no provisions for indexes in the SQL standard. so like, this is a PostgreSQL exclusive, iykyk 😌


πŸŽ€ SEE ALSO πŸŽ€

CREATE INDEX (CREATE_INDEX(7)) β€” the origin story, the prequel, the main character πŸ’–


that's the whole page, bestie, you ate that 🫢 this was PostgreSQL 15.19 documentation, dated 2026, and it's DROP INDEX(7) β€” now go forth and drop responsibly πŸ‘‘πŸ’œ

πŸ“¦ where this page comes from