Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id RAA57257 for ; Thu, 18 May 2000 17:48:14 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id RAA25360; Thu, 18 May 2000 17:47:56 -0400 (EDT) To: Kate Collins cc: postgresql news group Subject: Re: SQL command speed In-reply-to: <3924405E.15014E6B@wsicorp.com> References: <3924405E.15014E6B@wsicorp.com> Comments: In-reply-to Kate Collins message dated "Thu, 18 May 2000 15:11:27 -0400" Date: Thu, 18 May 2000 17:47:56 -0400 Message-ID: <25357.958686476@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200005/71 Kate Collins writes: > I did some experimentation, and if the WHERE clause had one or two items > it would use the index; more and it would not. Kate, it is reasonable behavior for the planner to stop using indexscans when there are enough OR clauses. Each OR clause requires a separate indexscan and so eventually it'll be cheaper to just do one sequential scan over the whole table. What we appear to have here is a case of misestimation of the relative costs of index and sequential scans, leading the planner to switch too soon. Next question is why the misestimation. It's difficult to say anything without seeing your EXPLAIN results for different numbers of OR clauses. Also, how big is the table (how many rows) and how many rows do you actually get from the query? regards, tom lane