Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 1BA4963271A for ; Sun, 28 Feb 2010 16:20:17 -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 82477-10 for ; Sun, 28 Feb 2010 20:20:03 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from glacier.frostconsultingllc.com (glacier.frostconsultingllc.com [69.36.227.170]) by mail.postgresql.org (Postfix) with ESMTP id 6D5D863264C for ; Sun, 28 Feb 2010 16:20:06 -0400 (AST) Received: from adsl-63-195-55-98.dsl.snfc21.pacbell.net ([63.195.55.98] helo=Sidney-Stratton.local) by glacier.frostconsultingllc.com with esmtpsa (TLSv1:CAMELLIA256-SHA:256) (Exim 4.69) (envelope-from ) id 1NlpcQ-00044m-DF for pgsql-performance@postgresql.org; Sun, 28 Feb 2010 12:20:04 -0800 Message-ID: <4B8ACFE7.6040207@agliodbs.com> Date: Sun, 28 Feb 2010 12:19:51 -0800 From: Josh Berkus User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1b3pre) Gecko/20090223 Thunderbird/3.0b2 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Estimation issue with partitioned tables Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.363 tagged_above=-10 required=5 tests=AWL=-0.409, BAYES_05=-1.11, SUBJECT_FUZZY_TION=0.156 X-Spam-Level: X-Archive-Number: 201002/399 X-Sequence-Number: 37820 All, I'm seeing in a production database two problems with query rowcount estimation: (1) Estimates for the number of rows in an outer join do not take into account any constraint exclusion (CE) in operation. (2) Row estimates do not take into account if the unique indexes on the child partitions are different from the master partition (the append node). This is often true, because the key to the master is ( key, ce column) and for the children is just ( key ). The result is that if you do a series of outer joins using the CE criterion against partitioned tables, the row estimates you get will be several orders of magnitude too high ... and the subsequent query plan far too pessimistic. Anyone else seeing this? Do any of the 9.0 patches address the above issues? --Josh Berkus