Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WtfPg-0004nw-31 for pgsql-performance@arkaria.postgresql.org; Sun, 08 Jun 2014 15:53:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WtfPe-0004Hm-Di for pgsql-performance@arkaria.postgresql.org; Sun, 08 Jun 2014 15:53:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1WtfPc-0004Gu-AT for pgsql-performance@postgresql.org; Sun, 08 Jun 2014 15:53:36 +0000 Received: from sam.nabble.com ([216.139.236.26]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1WtfPX-0000sr-8K for pgsql-performance@postgresql.org; Sun, 08 Jun 2014 15:53:34 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1WtfPT-0007Cs-Uq for pgsql-performance@postgresql.org; Sun, 08 Jun 2014 08:53:27 -0700 Date: Sun, 8 Jun 2014 08:53:27 -0700 (PDT) From: David G Johnston To: pgsql-performance@postgresql.org Message-ID: <1402242807947-5806450.post@n5.nabble.com> In-Reply-To: <1402235935505-5806445.post@n5.nabble.com> References: <4D00B4DE.3030508@xgs-france.com> <1402235935505-5806445.post@n5.nabble.com> Subject: Re: UNION and bad performance MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 0.8 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org pinker wrote >>> rhaas=# explain select a from generate_series(1,100) a union select a >>> from generate_series(1,100) a; >>> QUERY PLAN >>> -------------------------------------------------------------------------------------- >>> HashAggregate (cost=45.00..65.00 rows=2000 width=4) >>> -> Append (cost=0.00..40.00 rows=2000 width=4) > > > Why in this case the estimated number of rows is 2000? Is it standard > planner behavior? http://www.postgresql.org/docs/9.1/static/sql-createfunction.html Note the "ROWS" property. Functions are black-boxes to the planner so it has no means of estimating a row count. So a set returning function uses 1,000 and all others use 1. Determining "COST" is similarly problematic. David J. -- View this message in context: http://postgresql.1045698.n5.nabble.com/UNION-and-bad-performance-tp3301375p5806450.html Sent from the PostgreSQL - performance mailing list archive at Nabble.com. -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance