DROP_INDEX(7pg13)

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

πŸ’… 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 normal DROP INDEX acquires an ACCESS EXCLUSIVE lock 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 - The CASCADE option is not supported - (Thus, an index that supports a UNIQUE or PRIMARY KEY constraint cannot be dropped this way. Sorry bestie πŸ’€) - Regular DROP INDEX commands can be performed within a transaction block, but DROP INDEX CONCURRENTLY cannot - 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 ⭐


πŸ’œ 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