Re: Suppressing unused subquery output columns - Mailing list pgsql-hackers

From Rod Taylor
Subject Re: Suppressing unused subquery output columns
Date
Msg-id CAKddOFAKSL-FU8yC-AXOxH8XNF-y1C-LAoJv8_RK3-kY=0j8Eg@mail.gmail.com
Whole thread Raw
In response to Suppressing unused subquery output columns  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Suppressing unused subquery output columns  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Thu, Jun 5, 2014 at 10:27 PM, Tom Lane <tgl@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

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Suppressing unused subquery output columns
Next
From: Tom Lane
Date:
Subject: Re: Suppressing unused subquery output columns