Re: View vs. direct Table access

From: Darren Ferguson <darren(at)crystalballinc(dot)com>
To: Erwin Ambrosch <ambre(at)ebutec(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: View vs. direct Table access
Date: 2002-03-27 14:53:46
Message-ID: Pine.LNX.4.10.10203270952280.29945-100000@thread.crystalballinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

The reason the view is slower is because it has to be created first before
you can select from it.

I.e. every time you select from the view it will have to run the view sql
before it can select from it

Darren Ferguson

On Wed, 27 Mar 2002, Erwin Ambrosch wrote:

> Hi,
>
> we have a database with about 70 tables. Also we have a View over four tables
> which specifies three joins.
>
> Here is the View:
>
> CREATE VIEW company_view AS
> SELECT u.id, u.portalident, u.nikname, u.email, u.phone, u.mobile, u.fax,
> u.url, a.fname, a.sname, a.street, a.number, a.city, a.zip, co.name_de AS
> country, c.name AS cname, c.descr AS philosophy, c.logo_big AS logo,
> c.logo_small AS logo_small, c.brancheident
> FROM portal_user u, address a, company c, country co
> WHERE u.id = a.portal_userid
> AND u.id = c.portal_userid
> AND a.countryident = co.ident;
>
> While testing with about 10.000 rows in the tables joined by the view, we
> noticed that the selects, which use the View as their source, are very slow.
> So we did the same queries but accessing the tables directly not via the
> view, and the performace increased significantly.
>
> Are Views per default slower than direct table access? And if so is there a
> factor for calculationg the performace loss.
>
>
> Thanks in advance
>
> Erwin
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Doug McNaught 2002-03-27 15:01:51 Re: Difference between text and char(n)?
Previous Message Robert Wille 2002-03-27 14:52:27 Re: Why are selects so slow on large tables, even whenindexed?