pg.ddx.io pgsql-performance@postgresql.org mailing list archive
help / color / mirror / Atom feedView columns calculated
3+ messages / 3 participants
[nested] [flat]
* View columns calculated
@ 2004-04-13 20:49 Peter Darley <pdarley@kinesis-cem.com>
2004-04-13 21:23 ` Re: View columns calculated Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 3+ messages in thread
From: Peter Darley @ 2004-04-13 20:49 UTC (permalink / raw)
To: pgsql-performance
Folks,
I have a question about views: I want to have a fairly wide view (lots of
columns) where most of the columns have some heavyish calculations in them,
but I'm concerned that it will have to calculate every column even when I'm
not selecting them. So, the question is, if I have 5 columns in a view but
only select 1 column, is the system smart enough to not calculate the unused
columns, or am I taking a performance hit over a smaller view that doesn't
have the extra 4 columns?
Thanks,
Peter Darley
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: View columns calculated
2004-04-13 20:49 View columns calculated Peter Darley <pdarley@kinesis-cem.com>
@ 2004-04-13 21:23 ` Tom Lane <tgl@sss.pgh.pa.us>
2005-03-24 13:48 ` Re: View columns calculated Enrico Weigelt <weigelt@metux.de>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2004-04-13 21:23 UTC (permalink / raw)
To: Peter Darley <pdarley@kinesis-cem.com>; +Cc: pgsql-performance
"Peter Darley" <pdarley@kinesis-cem.com> writes:
> I have a question about views: I want to have a fairly wide view (lots of
> columns) where most of the columns have some heavyish calculations in them,
> but I'm concerned that it will have to calculate every column even when I'm
> not selecting them. So, the question is, if I have 5 columns in a view but
> only select 1 column, is the system smart enough to not calculate the unused
> columns,
It depends on what the rest of your view looks like. If the view is
simple enough to be "flattened" into the parent query then the unused
columns will disappear into the ether. If it's not flattenable then
they will get evaluated. You can check by seeing whether an EXPLAIN
shows a separate "subquery scan" node corresponding to the view.
(Without bothering to look at the code, an unflattenable view is one
that uses GROUP BY, DISTINCT, aggregates, ORDER BY, LIMIT, UNION,
INTERSECT, EXCEPT, probably a couple other things.)
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: View columns calculated
2004-04-13 20:49 View columns calculated Peter Darley <pdarley@kinesis-cem.com>
2004-04-13 21:23 ` Re: View columns calculated Tom Lane <tgl@sss.pgh.pa.us>
@ 2005-03-24 13:48 ` Enrico Weigelt <weigelt@metux.de>
0 siblings, 0 replies; 3+ messages in thread
From: Enrico Weigelt @ 2005-03-24 13:48 UTC (permalink / raw)
To: pgsql-performance
* Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "Peter Darley" <pdarley@kinesis-cem.com> writes:
> > I have a question about views: I want to have a fairly wide view (lots of
> > columns) where most of the columns have some heavyish calculations in them,
> > but I'm concerned that it will have to calculate every column even when I'm
> > not selecting them. So, the question is, if I have 5 columns in a view but
> > only select 1 column, is the system smart enough to not calculate the unused
> > columns,
>
> It depends on what the rest of your view looks like. If the view is
> simple enough to be "flattened" into the parent query then the unused
> columns will disappear into the ether. If it's not flattenable then
> they will get evaluated. You can check by seeing whether an EXPLAIN
> shows a separate "subquery scan" node corresponding to the view.
> (Without bothering to look at the code, an unflattenable view is one
> that uses GROUP BY, DISTINCT, aggregates, ORDER BY, LIMIT, UNION,
> INTERSECT, EXCEPT, probably a couple other things.)
What about functions ?
I'm using several (immutable) functions for mapping IDs to names, etc.
cu
--
---------------------------------------------------------------------
Enrico Weigelt == metux IT service
phone: +49 36207 519931 www: http://www.metux.de/
fax: +49 36207 519932 email: contact@metux.de
cellphone: +49 174 7066481
---------------------------------------------------------------------
-- DSL ab 0 Euro. -- statische IP -- UUCP -- Hosting -- Webshops --
---------------------------------------------------------------------
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2005-03-24 13:48 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-04-13 20:49 View columns calculated Peter Darley <pdarley@kinesis-cem.com>
2004-04-13 21:23 ` Tom Lane <tgl@sss.pgh.pa.us>
2005-03-24 13:48 ` Enrico Weigelt <weigelt@metux.de>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox