pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Carmen Sarlo <SarloC@Jevic.com>
Cc: 'dev@archonet.com' <dev@archonet.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Poor performance on a right join
Date: Mon, 17 Mar 2003 15:30:40 -0500
Message-ID: <8129.1047933040@sss.pgh.pa.us> (raw)
In-Reply-To: <3BCE0BA7092FD311BE570008C75DB4F80A46ABB4@EXCHANGE>
References: <3BCE0BA7092FD311BE570008C75DB4F80A46ABB4@EXCHANGE>

Carmen Sarlo <SarloC@Jevic.com> writes:
> EXPLAIN ANALYZE SELECT a.CALL_DATE, a.OPERATOR_ID, a.CUST_CODE FROM 
> PHONE as b right join CALLHIST as a on (a.CUST_CODE=b.CUST_CODE) where
> (b.PHONE = '847-478-2100') order by a.call_date desc;

This query is rather pointless as-is: the WHERE clause will eliminate
any null-extended rows produced by the RIGHT JOIN (because null b.PHONE
cannot satisfy the '=' condition).  So you may as well reduce the right
join to a plain join.  That will result in a much better plan, because
then the WHERE clause can be pushed down to the scan of b.

7.4 will be bright enough to make that deduction by itself, but 7.3 is
not, and certainly not 7.2 ...

			regards, tom lane



view thread (6+ messages)  latest in thread

Message-ID: <8129.1047933040@sss.pgh.pa.us>
Permalink:  ../8129.1047933040@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/8129.1047933040@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, SarloC@Jevic.com, dev@archonet.com
  Subject: Re: Poor performance on a right join
  In-Reply-To: <8129.1047933040@sss.pgh.pa.us>

* 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