On Thu, Jun 5, 2014 at 10:27 PM, Tom Lane <t...@sss.pgh.pa.us> wrote:
> I'm not entirely convinced that it's worth the extra planning cycles, > though. Given the small number of complaints to date, it might not > be worth doing this. Thoughts? > Would this avoid execution of expensive functions in views when their output is discarded? -- On 9.3 CREATE TABLE data (col1 serial primary key); INSERT INTO data DEFAULT VALUES; INSERT INTO data DEFAULT VALUES; CREATE OR REPLACE VIEW v AS select *, (pg_sleep(1))::text FROM data; t=# explain analyze select col1 from v; QUERY PLAN -------------------------------------------------------------------------------------------------------------- Subquery Scan on v (cost=0.00..76.00 rows=2400 width=4) (actual time=1001.086..2002.217 rows=2 loops=1) -> Seq Scan on data (cost=0.00..52.00 rows=2400 width=4) (actual time=1001.083..2002.210 rows=2 loops=1) Total runtime: 2002.268 ms (3 rows) regards, Rod