pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Eric Schwarzenbach <subscriber@blackbrook.org>
To: pgsql-performance@postgresql.org
Subject: view columns and performance
Date: Fri, 30 Jul 2010 10:55:32 -0400
Message-ID: <4C52E7E4.4020204@blackbrook.org> (raw)

I'm wondering whether columns, in the select list of a view that is used 
in a join, which are not used either as join criteria or in the select 
list of the overall query, effect the performance of the query.

In other words supposed I define a view something like

CREATE view MyView AS SELECT a,b, c, d, e, f, g FROM  (several tables 
joined together)

Assume for the sake of simplicity there are no aggregates or such, we're 
just joining tables, and getting a bunch of columns back each of the 
various tables.

I then then perform a query something like

SELECT v.a, x.h, y.i FROM MyView as v JOIN otherTable as x on (x.m = 
v.a) JOIN yetAnotherTable as y on (y.n=v.a)

Does all the extra clutter of b,c,d,e,f in MyView affect the performance 
of the query by taking up extra space in memory during the joins or is 
the optimizer smart enough to realize that they aren't needed and evoke 
the query as if MyView were really defined as

CREATE view MyView AS SELECT a FROM  (several tables joined together)?

Thanks,

Eric



view thread (2+ messages)  latest in thread

Message-ID: <4C52E7E4.4020204@blackbrook.org>
Permalink:  ../4C52E7E4.4020204@blackbrook.org/
Also on:    postgresql.org/message-id/4C52E7E4.4020204@blackbrook.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: subscriber@blackbrook.org
  Subject: Re: view columns and performance
  In-Reply-To: <4C52E7E4.4020204@blackbrook.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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