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 7D6138B9EE9 for ; Mon, 7 Feb 2005 09:07:24 +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 20441-07 for ; Mon, 7 Feb 2005 09:07:15 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.200]) by svr1.postgresql.org (Postfix) with ESMTP id 0A1288B9E44 for ; Mon, 7 Feb 2005 09:07:16 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 71so859473wra for ; Mon, 07 Feb 2005 01:07:15 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=XfjS1UhET0g2/CKrjEAldVcxECJLrQm5sK+kE3SmQ39Mv/2JHQwW404V1vrAh3Q5wMVs9IuuNpMvi353NAfDI9tdjy2vZJxBkzTlCgubRxxGY76ku1XayBpuVolsdpLUyBOW6RVLYNZQtrJpsBxdpGsUzQAdL7bdamj7oYQLapY= Received: by 10.54.50.3 with SMTP id x3mr102185wrx; Mon, 07 Feb 2005 01:07:15 -0800 (PST) Received: by 10.54.31.32 with HTTP; Mon, 7 Feb 2005 01:07:15 -0800 (PST) Message-ID: <2989532e05020701073638ca4c@mail.gmail.com> Date: Mon, 7 Feb 2005 14:37:15 +0530 From: Antony Paul Reply-To: Antony Paul To: pgsql-performance@postgresql.org Subject: Index not used with or condition Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.54 tagged_above=0 required=5 tests=FROM_ENDS_IN_NUMS, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200502/106 X-Sequence-Number: 10435 Hi all, I am facing a strange problem when I run EXPLAIN against a table having more than 100000 records. The query have lot of OR conditions and when parts of the query is removed it is using index. To analyse it I created a table with a single column, inserted 100000 records(random number) in it created index and run a query which returns 1 record which have no or condition and it was using index. I added an OR conditon and is using sequential scan. I set the enable_seqscan to off. I ran the tests again and is using index scan. So which one I have to use. Is this any bug in Explain. rgds Antony Paul.