pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: ta145@yahoo.com
To: pgsql-general@postgresql.org
To: pgsql-php@postgresql.org
To: pgsql-sql@postgresql.org
Subject: Re: looking to speed up SELECT ... LEFT JOIN query
Date: Thu, 8 Aug 2002 15:24:17 +0100
Message-ID: <200208081524.17392.dev@archonet.com> (raw)
In-Reply-To: <1b23bd38.0208062103.3ec45a2b@posting.google.com>
References: <1b23bd38.0208062103.3ec45a2b@posting.google.com>

On Wednesday 07 Aug 2002 6:03 am, Trey Ackerman wrote:
> Hi,
>
> I have a working SELECT statement using LEFT JOIN but I'm hoping
> someone can suggest something that might be a bit quicker (currently 3
> seconds for result).
>
> SELECT * FROM ((table1 LEFT JOIN table2 USING (custno)) AS j1
>          LEFT JOIN table3 USING (custno)) AS j2
>          LEFT JOIN table4 USING (custno)
>          WHERE custno='$custno';
>
> The primary table is table1, the key for all tables is 'custno'.  I
> need the LEFT JOIN because any one or all of the other tables (table2,
> table3, table4) might not have corresponding data.

We'll need to see the output of an EXPLAIN / EXPLAIN ANALYSE - also could you 
join the tables in a different order, smallest first?

- Richard Huxton



view thread (2+ messages)

Message-ID: <200208081524.17392.dev@archonet.com>
Permalink:  ../200208081524.17392.dev@archonet.com/
Also on:    postgresql.org/message-id/200208081524.17392.dev@archonet.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: dev@archonet.com, ta145@yahoo.com, pgsql-general@postgresql.org, pgsql-php@postgresql.org
  Subject: Re: looking to speed up SELECT ... LEFT JOIN query
  In-Reply-To: <200208081524.17392.dev@archonet.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