Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id D25351337BF7 for ; Fri, 29 Apr 2011 17:58:47 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 31086-05-4 for ; Fri, 29 Apr 2011 20:58:29 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 097271337C14 for ; Fri, 29 Apr 2011 17:58:24 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p3TKwMYK013919; Fri, 29 Apr 2011 16:58:22 -0400 (EDT) To: "Kevin Grittner" cc: "Wayne Conrad" , pgsql-performance@postgresql.org Subject: Re: 8.4.7, incorrect estimate In-reply-to: <4DBACC43020000250003D070@gw.wicourts.gov> References: <4DBB024B.5050500@databill.com> <4DBACC43020000250003D070@gw.wicourts.gov> Comments: In-reply-to "Kevin Grittner" message dated "Fri, 29 Apr 2011 14:33:39 -0500" Date: Fri, 29 Apr 2011 16:58:21 -0400 Message-ID: <13918.1304110701@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201104/424 X-Sequence-Number: 43486 "Kevin Grittner" writes: > Also, make sure that you run ANALYZE against your temp table right > before running your query. Yeah. It's fairly hard to credit that temp_document_ids has any stats given the way-off estimates for it. Keep in mind that autovacuum can't help you on temp tables: since only your own session can access a temp table, you have to ANALYZE it explicitly if you need the planner to have decent stats about it. regards, tom lane