Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id C7D66B5D803 for ; Sun, 10 Jul 2011 13:06:08 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 14146-02 for ; Sun, 10 Jul 2011 16:06:02 +0000 (UTC) X-Greylist: delayed 00:19:33.090202 by SQLgrey-1.7.6 Received: from wizmail.org (wizmail.org [217.146.107.12]) by mail.postgresql.org (Postfix) with ESMTP id 8D62FB5DC01 for ; Sun, 10 Jul 2011 13:06:02 -0300 (ADT) Received: from trunk.jgh.adsl.wizards.co.uk ([217.146.123.57] helo=ebony.jgh.adsl.wizards.co.uk) from_AS 16353 by wizmail.org with esmtpsa (TLSv1:DHE-RSA-CAMELLIA256-SHA:256) (Exim 4.72) id 1QfwDI-0007DY-Rh (return-path ); Sun, 10 Jul 2011 15:46:33 +0000 Message-ID: <4E19C951.1050109@wizmail.org> Date: Sun, 10 Jul 2011 16:46:25 +0100 From: Jeremy Harris User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.21) Gecko/20090320 Fedora/2.0.0.21-1.fc9 Thunderbird/2.0.0.21 Mnenhy/0.7.5.0 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: issue with query optimizer when joining two partitioned tables References: <4E180920.8040806@enterprisedb.com> <7806.1310233430@sss.pgh.pa.us> In-Reply-To: <7806.1310233430@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 201107/79 X-Sequence-Number: 44291 On 2011-07-09 18:43, Tom Lane wrote: > Heikki Linnakangas writes: >> On 09.07.2011 00:36, Anish Kejariwal wrote: >>> My guess as to what happened: >>> -because the icecream parent table has zero records, the query optimizer >>> chooses the incorrect execution plan >>> -when I do select * from icecream, the optimizer now knows how many records >>> are really in the icecream table, by knowing that the icecream table has >>> partitions. > >> "select * from icecream" won't have any direct effect on the >> optimization of subsequent queries. What probably happened is that >> autoanalyze ran in the background while you ran that select, and >> analyzed some of the partitions. Simply waiting a while would've had the >> same effect. > > Yeah. Also, the reason that a manual vacuum on icecream changes things > yet again is that in 9.0 and up, we have a notion of summary stats > across the whole inheritance tree, but autoanalyze hasn't been taught to > gather those. The manual command on the parent table does gather them, > though. Is stats-gathering significantly more expensive than an FTS? Could an FTS update stats as a matter of course (or perhaps only if enough changes in table)? -- Jeremy