DROP_INDEX(7pg18)

๐Ÿ“ฆ version 18.6, in opensuse-leap 16.0

๐Ÿ’… DROP INDEX โ€” the "okay bye bestie" of indexes

postgresql 18.6 docs ยท DROP INDEX(7) ยท yes this is the manual page, no I will not be normal about it


โœจ NAME โœจ

DROP_INDEX โ€” remove an index. that's it. that's the whole vibe. it's giving "we're deleting the thing."


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

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

look at her. so simple. so powerful. slay.


๐Ÿ’– DESCRIPTION ๐Ÿ’–

okay so DROP INDEX drops an existing index from the database system. gone. deleted. no more index. โœจ

one lil' thing though: to actually run this command you must be the owner of the index. if you're not the owner, bestie, this is not your moment. ๐Ÿ’€


๐Ÿฆ‹ PARAMETERS ๐Ÿฆ‹

  • CONCURRENTLY โ€” drops the index without locking out concurrent selects, inserts, updates, and deletes on the index's table. lowkey the polite option. a normal DROP INDEX grabs an ACCESS EXCLUSIVE lock on the table, which blocks literally everyone else until the drop finishes. with this option, the command instead just waits until conflicting transactions have completed. patient queen behavior. ๐Ÿ‘‘
โš ๏ธ but babes, there are SEVERAL caveats here and you need to know all of them: - only one index name can be specified, so no comma-list shenanigans - the CASCADE option is not supported with this - (which means an index that supports a UNIQUE or PRIMARY KEY constraint cannot be dropped this way โ€” it's giving "trapped by your own commitments" ๐Ÿ˜ญ) - 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. no. not happening.

and for temporary tables? DROP INDEX is always non-concurrent, because no other session can access them anyway, and a non-concurrent index drop is cheaper. like why take the scenic route, fr fr. ๐Ÿš—

  • IF EXISTS โ€” do not throw an error if the index does not exist. instead, a notice is issued in this case. it's the "no worries if not!!" of flags ๐Ÿซถ
  • name โ€” the name (optionally schema-qualified) of an index to remove. yes you can schema-qualify her. she's flexible like that. ๐ŸŒธ
  • CASCADE โ€” automatically drops objects that depend on the index, and in turn all objects that depend on those objects (see Section 5.15). it's a whole domino situation. one falls, they all fall. ๐Ÿ’€
  • RESTRICT โ€” refuses to drop the index if any objects depend on it. this is the default. respectful. cautious. boundaries. ๐ŸŽ€

โญ EXAMPLES โญ

this command will remove the index title_idx:

DROP INDEX title_idx;

and that's it. she's gone. bye girl ๐Ÿ‘‹๐Ÿ’–


๐ŸŒˆ COMPATIBILITY ๐ŸŒˆ

DROP INDEX is a PostgreSQL language extension. there are no provisions for indexes in the SQL standard. so like, this is our thing. it's giving "iykyk" โœจ


๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘

  • CREATE INDEX (CREATE_INDEX(7)) โ€” for when you inevitably need her back, bestie. the circle of life. ๐Ÿฆ‹

mwah ๐Ÿ’‹ that was PostgreSQL 18.6 docs, dated 2026, and this page is DROP INDEX(7). go forth and drop responsibly. no cap. ๐Ÿ’…โœจ

๐Ÿ“ฆ where this page comes from