Justin <justin@emproshunts.com> writes:
> The idea of ad hoc indexes is speed up loop scans To prove my idea i
> created a sql file in PGAdmin that creates the indexes on the fly then
> runs the query then drops the indexs.
> without the indexes it takes 18 to 19 seconds to run the query.
> To create the index and do the query takes 400 milliseconds.
The example you show doesn't convince me of much of anything, because
the estimated rowcounts are so far off. I think you're basically
dealing with an estimation failure and it's pure luck that the extra
index fixes it.
regards, tom lane