X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 100C33A4520 for ; Thu, 4 Nov 2004 14:52:15 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 84127-09 for ; Thu, 4 Nov 2004 14:52:06 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id E37DC3A3FC0 for ; Thu, 4 Nov 2004 14:52:09 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA4Eq3Dg025182; Thu, 4 Nov 2004 09:52:03 -0500 (EST) To: Mario Ivankovits Cc: pgsql-performance@postgresql.org Subject: Re: index not used if using IN or OR In-reply-to: <4189E086.5060400@ops.co.at> References: <4189E086.5060400@ops.co.at> Comments: In-reply-to Mario Ivankovits message dated "Thu, 04 Nov 2004 08:55:50 +0100" Date: Thu, 04 Nov 2004 09:52:03 -0500 Message-ID: <25181.1099579923@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/44 X-Sequence-Number: 8998 Mario Ivankovits 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