Re: are views typically any faster/slower than equivilent joins?

From: Rod Taylor <rbt(at)rbt(dot)ca>
To: Brian Tarbox <btarbox(at)theworld(dot)com>
Cc: Postgresql Performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: are views typically any faster/slower than equivilent joins?
Date: 2003-06-01 04:02:39
Message-ID: 1054440158.11968.86.camel@jester
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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(at)rbt(dot)ca>

PGP Key: http://www.rbt.ca/rbtpub.asc

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Rod Taylor 2003-06-01 04:05:56 Re: are views typically any faster/slower than equivilent joins?
Previous Message Brian Tarbox 2003-06-01 02:55:18 are views typically any faster/slower than equivilent joins?