Re: UNION and bad performance - Mailing list pgsql-performance

From David G Johnston
Subject Re: UNION and bad performance
Date
Msg-id 1402242807947-5806450.post@n5.nabble.com
Whole thread Raw
In response to UNION and bad performance  (Olivier Pala <olivier.pala@xgs-france.com>)
List pgsql-performance
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.


pgsql-performance by date:

Previous
From: Scott Marlowe
Date:
Subject: Re:
Next
From: Shaun Thomas
Date:
Subject: Re: postgres files in use not staying in linux file cache