Sergey Burladyan <eshkinkot@gmail.com> writes:
> PostgreSQL 8.4.0 on i486-pc-linux-gnu, compiled by GCC gcc-4.3.real (Debian 4.3.3-13) 4.3.3, 32-bit
> EXPLAIN ANALYZE select * from (select 1 as i, r from foo() r union all select 2, r from foo() r) as x where i = 3;
> QUERY PLAN
>
-----------------------------------------------------------------------------------------------------------------------
> Result (cost=0.00..0.53 rows=2 width=36) (actual time=10007.352..10007.352 rows=0 loops=1)
> -> Append (cost=0.00..0.53 rows=2 width=36) (actual time=10007.351..10007.351 rows=0 loops=1)
> -> Function Scan on foo r (cost=0.00..0.26 rows=1 width=36) (actual time=5003.342..5003.342 rows=0
loops=1)
> Filter: (1 = 3)
> -> Function Scan on foo r (cost=0.00..0.26 rows=1 width=36) (actual time=5004.004..5004.004 rows=0
loops=1)
> Filter: (2 = 3)
> Total runtime: 10007.464 ms
As of CVS HEAD you get
QUERY PLAN
------------------------------------------------------------------------------------Result (cost=0.00..0.01 rows=1
width=0)(actual time=0.011..0.011 rows=0 loops=1) One-Time Filter: falseTotal runtime: 0.179 ms
(3 rows)
regards, tom lane