Re: View performance question - Mailing list pgsql-sql

From Tom Lane
Subject Re: View performance question
Date
Msg-id 4558.993229559@sss.pgh.pa.us
Whole thread Raw
In response to View performance question  ("Josh Berkus" <josh@agliodbs.com>)
List pgsql-sql
"Josh Berkus" <josh@agliodbs.com> writes:
> I created a view to support comprehensive reporting on one of the
> databases I work with.  Unfortunately, due to the structure of the
> database, which includes 25 reference tables, this requires 3 regular
> joins and about 40 LEFT OUTER JOINS, outputting about 100 columns.

I suppose this is a star schema, wherein rows of the main tables join
to at most one row of the "reference" tables?  If so, you probably want
to make sure you perform the join of the main tables before you start
outerjoining the reference tables onto them.  The syntax you are using
is constraining the planner to use what's probably not a good plan.
See
http://www.ca.postgresql.org/users-lounge/docs/7.1/postgres/explicit-joins.html
        regards, tom lane


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: Incremental sum ?
Next
From: Alex Pilosov
Date:
Subject: Re: View performance question