From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Ashok Agrawal <Ashok.Agrawal@Sun.COM>
Cc: pgsql-performance@postgresql.org
Subject: Re: Outer Join performance in PostgreSQL
Date: Wed, 9 Nov 2005 14:47:22 -0800 (PST)
Message-ID: <20051109144311.B34905@megazone.bigpanda.com> (raw)
In-Reply-To: <43725511.3040809@Sun.COM>
References: <43725511.3040809@Sun.COM>
On Wed, 9 Nov 2005, Ashok Agrawal wrote:
> I noticed outer join is very very slow in postgresql as compared
> to Oracle.
>
> SELECT a.dln_code, a.company_name,
> to_char(a.certificate_date,'DD-MON-YYYY'),
> to_char(a.certificate_type_id, '99'),
> COALESCE(b.certificate_type_description,'None') ,
> a.description, a.blanket_single, a.certificate_status,
> COALESCE(a.sun_legal_entity, 'None'),
> COALESCE(a.other_entity_name, 'None'),
> COALESCE(a.notes, 'None'),COALESCE(c.name, NULL),
> COALESCE(to_char(a.created_date,'DD-MON-YYYY'), 'N/A'),
> COALESCE(c.name, NULL),
> COALESCE(to_char(a.updated_date,'DD-MON-YYYY'), 'N/A'),
> COALESCE(e.name, NULL),
> COALESCE(to_char(a.approved_date,'DD-MON-YYYY'), 'N/A')
> FROM ((((ecms_cert_headers a
> LEFT OUTER JOIN taxpack_user c ON (a.created_by = c.emp_no))
> LEFT OUTER JOIN taxpack_user d ON (a.updated_by = d.emp_no))
> LEFT OUTER JOIN taxpack_user e ON (a.approved_by = e.emp_no))
> INNER JOIN ecms_certificate_types b ON
> (a.certificate_type_id= b.certificate_type_id ))
> WHERE a.dln_code = '17319'
I think in the above it's safe to do the inner join first, although
PostgreSQL won't determine that currently and that could have something to
do with the difference in performance if Oracle did reorder the joins.
If you were to run the query doing the INNER JOIN first, does that give
the correct results and run more quickly in PostgreSQL? In either case,
explain analyze output would be handy to find the actual times taken by
the steps.
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-performance@postgresql.org
Cc: sszabo@megazone.bigpanda.com, Ashok.Agrawal@Sun.COM
Subject: Re: Outer Join performance in PostgreSQL
In-Reply-To: <20051109144311.B34905@megazone.bigpanda.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