DROP_INDEX(7pg15)
π 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 normalDROP INDEXacquires anACCESS EXCLUSIVElock 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 theCASCADEoption is not supported. (thus, an index that supports aUNIQUEorPRIMARY KEYconstraint cannot be dropped this way.) π - also, regularDROP INDEXcommands can be performed within a transaction block, butDROP INDEX CONCURRENTLYcannot. π - lastly, indexes on partitioned tables cannot be dropped using this option. nope. not happening. π for temporary tables,DROP INDEXis 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
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-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