pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: LORRAINE DEWEY <LORRAINE.DEWEY@companiongroup.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Optomizing left outer joins
Date: Wed, 23 Apr 2003 13:51:53 -0700
Message-ID: <200304231351.53694.josh@agliodbs.com> (raw)
In-Reply-To: <NY20fb33-5d6a4829@companiongroup.com>
References: <NY20fb33-5d6a4829@companiongroup.com>

Lorraine,

> Perhaps I should have said that not only is the column optional, the entire
> row is optional.  I am trying to join a master table (contains insurance 
claim
> information) to an error table.  If the claim in the master table doesn't 
have
> any errors, there won't be a row for it in the error table.  When I select
> columns from both tables, I only get the errored claims.  That's why I was
> trying to use the outer join.

Well, an outer join is appropriate in that case.   However, a single outer 
join shouldn't be killing your queries -- in the example I gave, I eliminated 
19 outer joins to boost the client's performance.

I think the lack of indexes is your real albatross.    

> I like your advice about telling the customer about the workaround.  I'll
> definitely do that!  The workaround is pretty awkward: two select statements
> joined by "union all," then some subselects to pick out the unmatched 
records.
>  It returns the correct data and it's faster than the left join, but it 
takes
> a lot more code.  Anyway, I guess I'm stuck with it.

You probably are.   But make sure you tell the client that the lack of indexes 
is killing performance; even if it doesn't get fixed, your keister is 
covered.

-- 
-Josh Berkus
 Aglio Database Solutions
 San Francisco




view thread (5+ messages)  latest in thread

Message-ID: <200304231351.53694.josh@agliodbs.com>
Permalink:  ../200304231351.53694.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200304231351.53694.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, LORRAINE.DEWEY@companiongroup.com
  Subject: Re: Optomizing left outer joins
  In-Reply-To: <200304231351.53694.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