DROP_INDEX(7pg17)
π DROP_INDEX π
okay bestie, welcome to the DROP INDEX page straight out of the PostgreSQL 17.11 docs β this is the one where we yeet an index into the void ποΈβ¨
β¨ NAME β¨
DROP_INDEX β remove an index π«Ά
πΈ SYNOPSIS πΈ
DROP INDEX [ CONCURRENTLY ] [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
like, that's the whole vibe check right there π
π¦ DESCRIPTION π¦
DROP INDEX drops an existing index from the database system. literally just removes it, gone, no more π
π one tiny catch though: to run this command you must be the owner of the index. not your cousin, not your group chat, you. 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, blocking other accesses until the index drop can be completed π but with this option, the command instead just waits until conflicting transactions have completed. patient queen energy π§
bestie there are several caveats to be aware of when using this option, and you need to hear them:
- only one index name can be specified, and the
CASCADEoption is not supported. (thus, an index that supports aUNIQUEorPRIMARY KEYconstraint cannot be dropped this way π) - also, regular
DROP INDEXcommands can be performed within a transaction block, butDROP INDEX CONCURRENTLYcannot π« - lastly, indexes on partitioned tables cannot be dropped using this option π
for temporary tables, DROP INDEX is always non-concurrent, as no other session can access them, and non-concurrent index drop is cheaper π (cheaper?! we love a budget-friendly icon)
IF EXISTSβ do not throw an error if the index does not exist. a notice is issued in this case π’ no drama, just a lil heads upnameβ the name (optionally schema-qualified) of an index to remove. tell me which index babes, be specific πCASCADEβ automatically drop objects that depend on the index, and in turn all objects that depend on those objects (see Section 5.15). it's giving domino effect, it's giving chain reaction πRESTRICTβ refuse to drop the index if any objects depend on it. and plot twist: this is the default π safe, sensible, main character energy
π EXAMPLES π
this command will remove the index title_idx:
DROP INDEX title_idx;
slay, bye title_idx, you served your purpose π«‘β¨
β COMPATIBILITY β
DROP INDEX is a PostgreSQL language extension. there are no provisions for indexes in the SQL standard β like, the standard simply did not think about it, no cap π so this is a postgres-only flex, iykyk π
π SEE ALSO π
CREATE INDEX (CREATE_INDEX(7)) β the origin story, the prequel, go read it next bestie π¦
mwah π that's the page! brought to you by PostgreSQL 17.11, dated 2026 β DROP INDEX(7), and yes she ate ππ
β¨
π¦ where this page comes from
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-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