Re: Views- Advantages and Disadvantages

From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: Reece Hart <reece(at)harts(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Views- Advantages and Disadvantages
Date: 2007-05-09 22:54:24
Message-ID: 737058.4446.qm@web31807.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


--- Reece Hart <reece(at)harts(dot)net> wrote:
> I believe that you're mistaken, and you can see it rather easily by
> explaining a select on a view (or even a view of views). For example:
> View definition:
> SELECT pa.palias_id, pv.pseq_id, pa.origin_id, pa.alias,
> pa.descr, pa.tax_id, pv.ref_pseq_id, pv.added
> FROM paliasorigin pa, pseqalias pv
> WHERE pv.palias_id = pa.palias_id AND pv.is_current = true;

if you're only selectivity is "is_current = true", you will get a seq. scan no matter what.
However, I bet your explain plan would be much better if you added something like:

SELECT *
FROM View
WHERE origin_id = <some origin_id value>;

as long as you had an index on origin_id.

Regards,
Richard Broersma Jr.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Brent Wood 2007-05-10 00:51:18 Re: Views- Advantages and Disadvantages
Previous Message Jeff Davis 2007-05-09 22:52:44 Re: Replication for PG 8 recommendations