Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 2502164FD34 for ; Thu, 6 Nov 2008 12:44:10 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 84706-04 for ; Thu, 6 Nov 2008 12:44:09 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from pih-relay08.plus.net (pih-relay08.plus.net [212.159.14.20]) by mail.postgresql.org (Postfix) with ESMTP id 830A164FD2E for ; Thu, 6 Nov 2008 12:44:08 -0400 (AST) Received: from [84.51.143.99] (helo=server3.office.archonet.com) by pih-relay08.plus.net with esmtp (Exim) id 1Ky7xl-0007Po-LS; Thu, 06 Nov 2008 16:44:05 +0000 Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 7BB3A274051; Thu, 6 Nov 2008 16:44:05 +0000 (GMT) Message-ID: <49131ED5.80307@archonet.com> Date: Thu, 06 Nov 2008 16:44:05 +0000 From: Richard Huxton User-Agent: Thunderbird 2.0.0.17 (X11/20080914) MIME-Version: 1.0 To: =?UTF-8?B?0JLRltGC0LDQu9GW0Lkg0KLQuNC80YfQuNGI0LjQvQ==?= CC: pgsql-performance@postgresql.org Subject: Re: PostgreSQL OR performance References: <331e40660811050312u552cab53ifa88e493e1c4f7ac@mail.gmail.com> <1225902700.1432.53.camel@jdavis> <331e40660811060246m51df553egd4e2ba91f08d1434@mail.gmail.com> <29e3942f0811060426k5fe34b1av401a2dba62e4ae3c@mail.gmail.com> <331e40660811060833l49bf837em41ca88d4b2061ea1@mail.gmail.com> In-Reply-To: <331e40660811060833l49bf837em41ca88d4b2061ea1@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Plusnet-Relay: 1fe37705493e7b88ecd31c2e1ae62610 X-Archive-Number: 200811/30 X-Sequence-Number: 31761 =D0=92=D1=96=D1=82=D0=B0=D0=BB=D1=96=D0=B9 =D0=A2=D0=B8=D0=BC=D1=87=D0=B8= =D1=88=D0=B8=D0=BD wrote: > As you can see from other plans, it do have all the indexes to perform = it's > work fast (when given part by part). It simply do not wish to use them.= My > question: Is this a configuration problem or postgresql optimizer simpl= y > can't do such a query rewrite? I must admit, I haven't managed to figure out what your query is trying to do, but then that's a common problem with autogenerated queries. The main question that needs answering is why the planner thinks you're going to get 1.3 billion rows in the "or" query: "Nested Loop (cost=3D4588.13..960900482668.95 rows=3D1386158171 width=3D= 32)" You don't show "explain analyse" for this query, so there's no way of knowing how many rows get returned but presumably you're expecting around 88000. What does "explain analyse" return? --=20 Richard Huxton Archonet Ltd