Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id AF08F632DF4 for ; Sun, 31 Jan 2010 21:13:46 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 27409-02 for ; Mon, 1 Feb 2010 01:13:35 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.27]) by mail.postgresql.org (Postfix) with ESMTP id 0DD0D632B8C for ; Sun, 31 Jan 2010 21:13:35 -0400 (AST) Received: by ey-out-2122.google.com with SMTP id 9so811484eyd.33 for ; Sun, 31 Jan 2010 17:13:34 -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; bh=E6hezycPpjabhYIhWGig7ovDlKCy2PlPhFgX4vYjgLM=; b=kF9lYNoCSle9QsIG3iGsbRcYIU+EuaRlyTx49j9IPGnOwUVzLiZGfQvQzGHIdgP3fs esNDVeYwXsKAACX4WON9kaNobmdHw2BLdaDdAi1V6iCDkAkjbJDfdHSxvLHzpDquHBhV yeOWnVWdgBUtwgw8jfDVTtx3mS0NlgdMSlOJ4= 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; b=xIWSyeyVpdlJgCjQwgpo/sFRLpNKjSmpFBUTgLaUWUj1i6lZGy2kMAdQbq9BbQjyJ4 ITQC8uxWFudB9IEFZCRJHlKKSikOH8exJ4/LMMvUpgHgnwDxmJ8/05EPqvo0dQAuN9Uc 3UMfTDNYvPRJyPzPYO4ITCyqXu58iGnzDHYIw= MIME-Version: 1.0 Received: by 10.216.90.70 with SMTP id d48mr2405233wef.159.1264986814026; Sun, 31 Jan 2010 17:13:34 -0800 (PST) In-Reply-To: <1f30b80c1001311709u14758b64u162aad3ace527600@mail.gmail.com> References: <1f30b80c1001290049ub864091r8298fca3daa0eb69@mail.gmail.com> <1f30b80c1001311650q264dfda0uf9894cac3b9e0c3e@mail.gmail.com> <1f30b80c1001311702g3ed5e895gc6e504ffe23d7840@mail.gmail.com> <1f30b80c1001311709u14758b64u162aad3ace527600@mail.gmail.com> Date: Sun, 31 Jan 2010 18:13:33 -0700 Message-ID: Subject: Re: Fwd: Help required on query performance From: Scott Marlowe To: dclements89@gmail.com Cc: pgsql-sql Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201001/61 X-Sequence-Number: 33597 On Sun, Jan 31, 2010 at 6:09 PM, Dave Clements wrote: > I did the re-analyze serveral times, using the command: > > ANALYZE tablename; > > Is there any other command as well or another way to do that? It's important that the stats target get increased as well, it looks like you're not getting enough buckets to get a good estimate of rows to be returned for various conditions. # show default_statistics_target ; default_statistics_target --------------------------- 10 # alter database smarlowe set default_statistics_target=200; ALTER DATABASE # analyze; Then run the explain analyze again and see if your row estimates are closer and if the plan changes.