Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Andrew Bartley wrote:
>> The testing I have already done, an index is by far better in this
>> circumstance.
> If it is a non-temp table with the same data and VACUUM ANALYZE, does it
> use an index?
The default stats values used in the absence of any VACUUM are supposed
to yield an index search. Temp-ness is irrelevant. For example:
regression=# create temp table foo (f1 int primary key);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'foo_pkey' for table 'foo'
CREATE
regression=# explain select * from foo where f1 = 42;
INFO: QUERY PLAN:
Index Scan using foo_pkey on foo (cost=0.00..4.82 rows=1 width=4)
indxqual: (f1 = 42)
EXPLAIN
I'd be interested to see the details of Andrew's example where this
does not happen.
regards, tom lane