pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: Manuel Sugawara <masm@fciencias.unam.mx>
To: pgsql-sql@postgresql.org
Subject: Re: left join on a view takes significantly more time.
Date: Wed, 31 Mar 2004 15:49:29 -0800
Message-ID: <200403311549.29211.josh@agliodbs.com> (raw)
In-Reply-To: <m3wu50voaq.fsf@conexa.fciencias.unam.mx>
References: <m3wu50voaq.fsf@conexa.fciencias.unam.mx>

Manuel,

> I'm facing a wired problem. When I left join two tables PostgreSQL is
> able to do it fast using the corresponding indices, However, if I
> define a simple view (to format the data) on one of the tables, the
> left join does not use the indices. Is something wrong here?

At a guess, the complex CASE statements are causing the planner to behave 
badly.   What happens if you do a straight join and not a left join?

Also, it's generally a good idea to put your join expression in the same order 
as the referenced tables.  You confused me and you could confuse the planner 
at some stage.

-- 
-Josh Berkus
 Aglio Database Solutions
 San Francisco




view thread (2+ messages)

Message-ID: <200403311549.29211.josh@agliodbs.com>
Permalink:  ../200403311549.29211.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200403311549.29211.josh@agliodbs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: josh@agliodbs.com, masm@fciencias.unam.mx
  Subject: Re: left join on a view takes significantly more time.
  In-Reply-To: <200403311549.29211.josh@agliodbs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox