Re: index not used if using IN or OR - Mailing list pgsql-performance

From Tom Lane
Subject Re: index not used if using IN or OR
Date
Msg-id 25181.1099579923@sss.pgh.pa.us
Whole thread Raw
In response to index not used if using IN or OR  (Mario Ivankovits <mario@ops.co.at>)
List pgsql-performance
Mario Ivankovits <mario@ops.co.at> writes:
> After populating the table with 8920 records and "analyze" the scenario
> gets even worser:

> select * from tt where seckey = 1;
> Seq Scan on tt  (cost=0.00..168.50 rows=1669 width=12) (actual
> time=0.000..15.000 rows=1784 loops=1)
>   Filter: (seckey = 1)
> Total runtime: 31.000 ms

> Now also this simple query uses a "Seq Scan".

Which is exactly what it *should* do, considering that it is selecting
1784 out of 8920 records.  Indexscans only win for small selectivities
--- the rule of thumb is that retrieving more than about 1% of the
records should use a seqscan.

            regards, tom lane

pgsql-performance by date:

Previous
From: Andrew Sullivan
Date:
Subject: Re: preloading indexes
Next
From: Martin Foster
Date:
Subject: Re: Restricting Postgres