Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YIfVl-000113-BA for pgsql-admin@arkaria.postgresql.org; Tue, 03 Feb 2015 15:35:33 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YIfVk-0005xG-51 for pgsql-admin@arkaria.postgresql.org; Tue, 03 Feb 2015 15:35:32 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YIfVi-0005x5-VB for pgsql-admin@postgresql.org; Tue, 03 Feb 2015 15:35:31 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YIfVf-00032X-KZ for pgsql-admin@postgresql.org; Tue, 03 Feb 2015 15:35:29 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t13FZOc6003457; Tue, 3 Feb 2015 10:35:24 -0500 From: Tom Lane To: Nino Arsov cc: pgsql-admin@postgresql.org Subject: Re: Estimating the execution cost of a query in a partitioned schema: Weird execution plans and totally wrong execution costs (pg_class and pg_statistic) In-reply-to: References: Comments: In-reply-to Nino Arsov message dated "Tue, 03 Feb 2015 12:35:27 +0100" Date: Tue, 03 Feb 2015 10:35:24 -0500 Message-ID: <3456.1422977724@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org Nino Arsov writes: > Using EXPLAIN we have successfully managed to get very similar execution > plans and costs by the planner as if there were data in the newly created > partitions. This method works just fine as long as the queries to be > estimated consist of a join of no more than 2 tables. > When we try to estimate a query's cost that contains a join between 3 or > more tables we get huge costs and wrong plans (in the rank of millions of > cost units). When data is actually loaded into all of the partitions, the > cost does not exceed a few thousand cost units. Have you modified the planner at all? Because it's a bit hard to see how inserting faked-up statistics as described would work properly in a 2-way join but not in a 3-way join. A bug in some hack or other would be a much more plausible explanation. I'm also curious about exactly how you're inserting new data into pg_statistic --- the "anyarray" columns that are used there are not readily modifiable from SQL. (This is pretty off-topic for pgsql-admin, btw.) regards, tom lane -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin