From: Rod Taylor <rbt@rbt.ca>
To: Brian Tarbox <btarbox@theworld.com>
Cc: Postgresql Performance <pgsql-performance@postgresql.org>
Subject: Re: are views typically any faster/slower than equivilent joins?
Date: 01 Jun 2003 00:02:39 -0400
Message-ID: <1054440158.11968.86.camel@jester> (raw)
In-Reply-To: <001801c327e9$3c01a5b0$01000001@trouble>
References: <001801c327e9$3c01a5b0$01000001@trouble>
On Sat, 2003-05-31 at 22:55, Brian Tarbox wrote:
> I am working with a highly normalized database. Most of my meaningful
> queries involve joins from a primary table to 4-6 secondary tables.
>
> Would my query performance be significantly faster/slower using a View as
> opposed to a prepared query using join?
There are some corner cases where a view would be slower than a standard
query in 7.3 (bug fix / disabled optimization -- fixed right in 7.4),
but generally you can assume it will be about the same speed.
Some views such as unions will not be as fast as you would like, but
thats a general issue with PostgreSQLs inability to throw away selects
when it won't find results on one side of a union.
CREATE VIEW sales AS SELECT * FROM sales_archive_2002 UNION ALL SELECT *
FROM sales_current;
SELECT * FROM sales WHERE timestamp => CURRENT_TIMESTAMP - INTERVAL '1
day';
The above query would not be so quick.
--
Rod Taylor <rbt@rbt.ca>
PGP Key: http://www.rbt.ca/rbtpub.ascAttachments:
signature.asc (application/pgp-signature, 186B) download
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: rbt@rbt.ca, btarbox@theworld.com
Subject: Re: are views typically any faster/slower than equivilent joins?
In-Reply-To: <1054440158.11968.86.camel@jester>
References: <001801c327e9$3c01a5b0$01000001@trouble> <1054440158.11968.86.camel@jester>
* 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