Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 3D2EB6342F5 for ; Tue, 10 Mar 2009 20:19:57 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 84898-09 for ; Tue, 10 Mar 2009 20:19:48 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from yw-out-2324.google.com (yw-out-2324.google.com [74.125.46.29]) by mail.postgresql.org (Postfix) with ESMTP id 5EB59633436 for ; Tue, 10 Mar 2009 20:19:55 -0300 (ADT) Received: by yw-out-2324.google.com with SMTP id 5so204402ywh.73 for ; Tue, 10 Mar 2009 16:19:54 -0700 (PDT) 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=Kqir7v0b13dW671beA385/Y1ukyDNkAuK+s8BY1CTto=; b=Sy2f9jBhdhCOb9iARjRTvkRUx3PixmVV3oYnTlkSekRzQB8089g5mVopIHfW4UXByW nKBFGrCR0XUpvYcdVqfEknwZJKtKgpBYF/nhHXpJsG8haAtg71NDPXskZgYPC7N6D0WW XmtScZJ0EnzigbLBd73RvesRv5A0IDm5DUPrA= 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=xOCDZ8JfQ67wdUdwehO6veS4JUYoudNcrlxspoUxeVehTpf5UCYcW4UKFpHMKKvr0/ Nov/oajmsJF6JYJJTTImo66jxdBaVeNyEV0EFZTaEm2ZvWbAgRkW9UnwBXiyDtnGxftB Gc17wN1Vl+eYyVWh4FGeH3IqazrLcXCN9X/Mk= MIME-Version: 1.0 Received: by 10.151.141.8 with SMTP id t8mr12666894ybn.112.1236727194023; Tue, 10 Mar 2009 16:19:54 -0700 (PDT) In-Reply-To: <1ca6422a7addad0207f758f54300dd0b.squirrel@semichrome.net> References: <1ca6422a7addad0207f758f54300dd0b.squirrel@semichrome.net> Date: Tue, 10 Mar 2009 17:19:53 -0600 Message-ID: Subject: Re: Query performance over a large proportion of data From: Scott Marlowe To: Steve McLellan 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=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200903/87 X-Sequence-Number: 33009 On Tue, Mar 10, 2009 at 3:12 PM, Steve McLellan wrot= e: > > =A0Nested Loop =A0(cost=3D466.34..192962.24 rows=3D15329 width=3D12) (act= ual > time=3D13653.238..31332.113 rows=3D131466 loops=3D1) Both your query plans end with this nested loop join which is taking up about half your time in your query. Notice the estimation of the result set is off by a factor of about 10 here, which means a nested loop might be not so good a choice for this. Try increasing default stats target and re-analyzing to see if that helps. 1000 is the max you can give that a shot right off to see if it helps. If it does, drop it until the numbers start to go off again and stop. For a quicker test, you can set enable_nestloop =3D off in the psql command line and then run the query by hand and see if that helps.