Archive for December 5th, 2006

 

Temporarily “Dropping” a PostgreSQL Index

Dec 05, 2006 in PostgreSQL

> BTW, the cute way to do that is
> 	BEGIN;
> 	DROP INDEX unwanted;
> 	EXPLAIN ANALYZE whatever...;
> 	ROLLBACK;
>
> No need to actually rebuild the index when you are done.
>
> This does hold an exclusive lock on the table for the duration of your
> experiment, so maybe not such a good idea in a live environment ... but
> then again, dropping useful indexes in a live environment isn't a good
> idea either, and this at least reduces the duration of the experiment by
> a good deal.

I found this comment by Tom Lane in the Postgresql mailing list archive yesterday. A pretty nifty trick, and perhaps something useful for inclusion in a university syllabus?