pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert John Shepherd <robert@reviewer.co.uk>
Cc: pgsql-performance@postgresql.org
Subject: Re: Do Views offer any performance advantage?
Date: Tue, 15 Apr 2003 13:26:23 -0400
Message-ID: <8832.1050427583@sss.pgh.pa.us> (raw)
In-Reply-To: <001f01c30366$93427720$f3b0313e@LAIKA>
References: <001f01c30366$93427720$f3b0313e@LAIKA>

"Robert John Shepherd" <robert@reviewer.co.uk> writes:
> Whilst I often use views for convenience, is there any performance
> advantage at all in using a view rather than running the same query
> directly on the tables themselves?

No, a view is just a macro.

There is probably some minuscule cost difference involved --- you save
parsing and parse analysis of a long query string.  On the other hand,
you pay to pull the view definition from the catalogs and merge it into
the given query.  I'd not care to hazard a guess on whether the actual
net cost is more or less; but in any case these costs will be swamped
by query planning and execution, if the query is complex.

If you're concerned about reducing parse/plan overhead for repetitive
queries, the prepared-statement facility (new in 7.3) is what to look
at.  Views won't do much for you.

			regards, tom lane




view thread (5+ messages)  latest in thread

Message-ID: <8832.1050427583@sss.pgh.pa.us>
Permalink:  ../8832.1050427583@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/8832.1050427583@sss.pgh.pa.us

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, robert@reviewer.co.uk
  Subject: Re: Do Views offer any performance advantage?
  In-Reply-To: <8832.1050427583@sss.pgh.pa.us>
  References: <001f01c30366$93427720$f3b0313e@LAIKA> <8832.1050427583@sss.pgh.pa.us>

* 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