DROP_INDEX(7pg13)
π DROP_INDEX β the "we're so over you" command
Okay bestie, so this is the DROP INDEX page from the PostgreSQL 13.23 docs (part of the 7pg13 manual set). It's a short one, but it's lowkey iconic, so let's get into it π«Ά
β¨ NAME β¨
DROP_INDEX β remove an index. That's it. That's the whole vibe. Girl's gotta go π
πΈ SYNOPSIS πΈ
DROP INDEX [ CONCURRENTLY ] [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
Look at that little line of brackets. Every single one is optional, bestie β it's giving choose your own adventure π¦
π DESCRIPTION π
So DROP INDEX literally drops an existing index right out of the database system. Poof. Gone. Not me being dramatic, it's just facts π
One thing though β to execute this command you must be the owner of the index. No ownership, no drop. Them's the rules, periodt.
π PARAMETERS π
CONCURRENTLYβ Drop the index without locking out concurrent selects, inserts, updates, and deletes on the index's table. Okay so here's why that matters: a normalDROP INDEXacquires anACCESS EXCLUSIVElock on the table, which blocks all other accesses until the index drop can be completed. Kind of rude, honestly π With this option though, the command instead waits until conflicting transactions have completed. So polite, so patient, we stan β¨
Lowkey there are several caveats to be aware of when using this option, and I need you to hear me on these: - Only one index name can be specified - TheCASCADEoption is not supported - (Thus, an index that supports aUNIQUEorPRIMARY KEYconstraint cannot be dropped this way. Sorry bestie π) - RegularDROP INDEXcommands can be performed within a transaction block, butDROP INDEX CONCURRENTLYcannot - 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. Makes sense β no audience, no need for the fancy footwork π§
IF EXISTSβ Do not throw an error if the index does not exist. A notice is issued in this case. So instead of screaming at you, it just kind of quietly notes it. Very demure πnameβ The name (optionally schema-qualified) of an index to remove. That's your target, bestie π―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 the domino effect β one goes, they all go πRESTRICTβ Refuse to drop the index if any objects depend on it. This is the default. Very "I'm not touching that, that's not my business" energy π
π EXAMPLES π
This command will remove the index title_idx:
DROP INDEX title_idx;
Slay. Bye title_idx π¦
π COMPATIBILITY π
DROP INDEX is a PostgreSQL language extension. There are no provisions for indexes in the SQL standard. So like, this is our thing. Main character energy only π
β SEE ALSO β
CREATE INDEX(CREATE_INDEX(7)) β the origin story, iykyk
π That's the whole page, bestie β go forth and drop responsibly π
Cute little sign-off from the footer: this is from PostgreSQL 13.23, dated 2025 β so you know it's the good stuff ππ₯
π¦ 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