Re: Performance issues

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, <vjoshi(at)zetainteractive(dot)com>, Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>, Varadharajan Mukundan <srinathsmn(at)gmail(dot)com>
Cc: <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Performance issues
Date: 2015-03-16 19:43:46
Message-ID: 55073272.20209@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 3/13/15 7:12 PM, Tomas Vondra wrote:
> (4) I suspect many of the relations referenced in the views are not
> actually needed in the query, i.e. the join is performed but
> then it's just discarded because those columns are not used.
> Try to simplify the views as much has possible - remove all the
> tables that are not really necessary to run the query. If two
> queries need different tables, maybe defining two views is
> a better approach.

A better alternative with multi-purpose views is to use an outer join
instead of an inner join. With an outer join if you ultimately don't
refer to any of the columns in a particular table Postgres will remove
the table from the query completely.
--
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Jim Nasby 2015-03-16 20:01:04 Re: MusicBrainz postgres performance issues
Previous Message Jim Nasby 2015-03-16 19:33:39 Re: Best VPS provider for running performant PostgreSQL database server