Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id A1E89632DF4 for ; Sun, 31 Jan 2010 21:22:46 -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 98334-06 for ; Mon, 1 Feb 2010 01:22:28 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pz0-f180.google.com (mail-pz0-f180.google.com [209.85.222.180]) by mail.postgresql.org (Postfix) with ESMTP id D880C632C3C for ; Sun, 31 Jan 2010 21:22:35 -0400 (AST) Received: by pzk10 with SMTP id 10so3585583pzk.19 for ; Sun, 31 Jan 2010 17:22:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:reply-to:received :in-reply-to:references:from:date:x-google-sender-auth:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=RTrIeztP/n61aGV6Y4EDXVpadstam/h9QAJk8c2ks4g=; b=vLjcOJMeqnvFIaEWgW7XQnkF8XBppd4yP0UJSt4Jcr0jGRYY4FkEw+H7HQkCrTKm2i I3xZyO29eOhxv/gIVUdDiptiOd6uXRDbg007nyh0ewv+tqZYNyZ98qQ4hOaH98EMnFjf ATL0/0jpBuxvGI+/vK/RpD+hqmvJIBwNFTKbU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:reply-to:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; b=MEWZ9g++L4ld/ukOfd/HfPxf9KhAVYQOX/g280jkOgJ/qRkDsqGXk7sWyiLJKC3wh/ 4G216NjNy92KIa8CYj3utPxvrNU4SFPjFn/1qKvjhBBv3sjHIBXjTpbgtBmFUR0Jsr0g u9u5l6j19Ll8msccCahv+AJtcXd9kTR5og568= MIME-Version: 1.0 Reply-To: dclements89@gmail.com Received: by 10.114.237.24 with SMTP id k24mr2694827wah.24.1264987353972; Sun, 31 Jan 2010 17:22:33 -0800 (PST) In-Reply-To: References: <1f30b80c1001290049ub864091r8298fca3daa0eb69@mail.gmail.com> <1f30b80c1001311650q264dfda0uf9894cac3b9e0c3e@mail.gmail.com> <1f30b80c1001311702g3ed5e895gc6e504ffe23d7840@mail.gmail.com> <1f30b80c1001311709u14758b64u162aad3ace527600@mail.gmail.com> From: Dave Clements Date: Mon, 1 Feb 2010 12:22:13 +1100 X-Google-Sender-Auth: 07e43a99ffe409e2 Message-ID: <1f30b80c1001311722y5f410655nf3fec0091dc2912c@mail.gmail.com> Subject: Re: Fwd: Help required on query performance To: Scott Marlowe Cc: pgsql-sql 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=-1.577 tagged_above=-10 required=5 tests=AWL=1.022, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201001/62 X-Sequence-Number: 33598 After doing an analyze on the database, it improved a lot :) On Mon, Feb 1, 2010 at 12:13 PM, Scott Marlowe wr= ote: > On Sun, Jan 31, 2010 at 6:09 PM, Dave Clements wr= ote: >> 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 ; > =A0default_statistics_target > --------------------------- > =A010 > > # alter database smarlowe set default_statistics_target=3D200; > ALTER DATABASE > # analyze; > > Then run the explain analyze again and see if your row estimates are > closer and if the plan changes. >