Re: Performance of full outer join in 8.3

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Performance of full outer join in 8.3
Date: 2009-04-16 11:44:53
Message-ID: 20090416114452.GL12225@frubble.xen.chris-lamb.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Thu, Apr 16, 2009 at 01:31:45PM +0200, Christian Schröder wrote:
> Stupid question: Do I have to analyze again or perform a reindex after
> adding the index?

No, it's a regression in PG's handling of outer joins---it used to
realise that this was a possible optimisation, but now it doesn't.

Tom Lane started discussion on -hackers about this issue:

http://archives.postgresql.org/pgsql-hackers/2009-04/msg00849.php

it looks as though performance in 8.3 is going to be bad until this
behaviour is changed. A possible fix is to rewrite your query to work
around the problem:

SELECT isin
FROM (SELECT * FROM ts_frontend.attachment_isins WHERE attachment = 2698120) a
FULL OUTER JOIN (SELECT * FROM ts_frontend.rec_isins WHERE attachment = 2698120) USING (isin)
GROUP BY isin
LIMIT 1000;

It looks as though what you're trying to do could also be expressed as:

SELECT isin FROM ts_frontend.rec_isins WHERE attachment = 2698120
UNION
SELECT isin FROM ts_frontend.attachment_isins WHERE attachment = 2698120;

not sure if it's part of something larger so this may not be a useful
transform.

--
Sam http://samason.me.uk/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message ahmed soua 2009-04-16 12:35:33 osm2pgsql error
Previous Message Robert Haas 2009-04-16 11:35:25 Re: [GENERAL] Performance of full outer join in 8.3

Browse pgsql-hackers by date

  From Date Subject
Next Message Marko Kreen 2009-04-16 11:47:20 Re: Unicode string literals versus the world
Previous Message Robert Haas 2009-04-16 11:35:25 Re: [GENERAL] Performance of full outer join in 8.3