Re: Do Views offer any performance advantage?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Robert John Shepherd" <robert(at)reviewer(dot)co(dot)uk>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Do Views offer any performance advantage?
Date: 2003-04-15 17:26:23
Message-ID: 8832.1050427583@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

"Robert John Shepherd" <robert(at)reviewer(dot)co(dot)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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Greg Stark 2003-04-15 19:04:04 Using indexes for like foo% type queries when foo isn't constant (not a locale issue)
Previous Message scott.marlowe 2003-04-15 16:34:21 Re: for help!