On Tue, Oct 04, 2005 at 09:32:41PM +0200, han.holl@xxxxxxxxxxxxxxxxxxxx wrote: > I've got a table with an index, let's call it fase. > > The following query is fine: 'select something from table where fase = '1'; > > However, this is disastrously slow: > select something from table where fase = '1' or fase = '2'; Could we see some EXPLAIN ANALYZE output? What version of PostgreSQL are you using? Have you run VACUUM ANALYZE on the table to remove dead tuples and update the statistics? Have you considered clustering the table on fase's index? It might be useful to see the output of the following queries, assuming the table name is foo: SET enable_seqscan TO on; SET enable_indexscan TO off; EXPLAIN ANALYZE SELECT something FROM foo WHERE fase = '1'; EXPLAIN ANALYZE SELECT something FROM foo WHERE fase = '2'; EXPLAIN ANALYZE SELECT something FROM foo WHERE fase = '1' OR fase = '2'; SET enable_seqscan TO off; SET enable_indexscan TO on; EXPLAIN ANALYZE SELECT something FROM foo WHERE fase = '1'; EXPLAIN ANALYZE SELECT something FROM foo WHERE fase = '2'; EXPLAIN ANALYZE SELECT something FROM foo WHERE fase = '1' OR fase = '2'; SHOW random_page_cost; SHOW effective_cache_size; SELECT version(); \x SELECT * FROM pg_stats WHERE tablename = 'foo' AND attname = 'fase'; BTW, pgsql-performance is a list dedicated to performance issues, so you might want to ask performance-related questions there. -- Michael Fuhr ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq