Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 1C7C3632796 for ; Mon, 15 Feb 2010 12:42:14 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 38633-07 for ; Mon, 15 Feb 2010 16:41:54 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-fx0-f220.google.com (mail-fx0-f220.google.com [209.85.220.220]) by mail.postgresql.org (Postfix) with ESMTP id A714C632572 for ; Mon, 15 Feb 2010 12:41:44 -0400 (AST) Received: by fxm20 with SMTP id 20so5453272fxm.21 for ; Mon, 15 Feb 2010 08:41:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=UMHU88IU4OncKjp9q7i6UeJmLMbbreivDYl7u09Z8+o=; b=ec0znOPKbL4e75zDxVXI6aJZLj6lf1Wn44K8HiJvBYpCFyDh3j4lISlBpgUpDgbwCK 9zl+F9TYKUD/nSZXRgjXGs1aXlYTcbNpByAkFiG5mBdiDynQuokdo1zTqDv27vkeHLM/ 5axUGaRS60lafNROBKrUTC49J8URDMe7YnM1Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=epgDddQ5Sp35rS0ACXvTy0d4DNazhlXaBaF+md70TbFroxLsmLt1ttjGfTBXGD/D2d BqlD3Q3pXVh6suZQgg0grD9qZktrcRbT1tBG7OKB/uP8brPPw/OYWrYtsILFszgjWT2q oFDGMZxAsRY+5wqDuyR2b3a58ZQcEcCifs+J8= MIME-Version: 1.0 Received: by 10.239.184.82 with SMTP id x18mr520889hbg.67.1266252103401; Mon, 15 Feb 2010 08:41:43 -0800 (PST) In-Reply-To: <4B765B94.4000602@obviously.com> References: <4B723042.7090406@obviously.com> <4B751AD5020000250002F248@gw.wicourts.gov> <4B757C59.8070500@denninger.net> <4B752934020000250002F24E@gw.wicourts.gov> <4B75851E.6070909@denninger.net> <26772.1266005254@sss.pgh.pa.us> <4B765B94.4000602@obviously.com> Date: Mon, 15 Feb 2010 11:41:43 -0500 Message-ID: <603c8f071002150841w53cda2f6l7901e7af06da862@mail.gmail.com> Subject: Re: 512,600ms query becomes 7500ms... but why? Postgres 8.3 query planner quirk? From: Robert Haas To: Bryce Nesbitt Cc: pgsql-performance@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.478 tagged_above=-10 required=5 tests=AWL=0.121, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201002/241 X-Sequence-Number: 37662 On Sat, Feb 13, 2010 at 2:58 AM, Bryce Nesbitt wrote= : > So as the op, back to the original posting.... > > In the real world, what should I do?=A0 Does it make sense to pull the "A= ND > articles.indexed" clause into an outer query?=A0 Will that query simply > perform poorly on other arbitrary combinations of words? It's really hard to say whether a query that performs better is going to always perform better on every combination of words. My suggestion is - try it and see. It's my experience that rewriting queries is a pretty effective way of speeding them up, but I can't vouch for what will happen in your particular case. It's depressing to see that increasing the statistics target didn't help much; but that makes me think that the problem is that your join selectivity estimates are off, as Tom and Jorge said upthread. Rewriting the query or trying an upgrade are probably your only options. ...Robert