Re: unnesesary sorting after Merge Full Join

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Decibel! <decibel(at)decibel(dot)org>
Cc: Alexey Nalbat <nalbat(at)price(dot)ru>, pgsql-general(at)postgresql(dot)org
Subject: Re: unnesesary sorting after Merge Full Join
Date: 2008-02-24 12:00:52
Message-ID: 1203854452.4249.5.camel@ebony.site
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, 2008-02-23 at 14:49 -0600, Decibel! wrote:
> On Feb 21, 2008, at 4:08 AM, Alexey Nalbat wrote:

> > I found comment in src/backend/optimizer/path/pathkeys.c:
> > * EXCEPTION: in a FULL or RIGHT join, we cannot treat the result as
> > * having the outer path's path keys, because null lefthand rows may be
> > * inserted at random points. It must be treated as unsorted.
> >
> > How can I get rid of this sorting? Or could this behavior of Merge
> > Full Join be improved?
>
> Theoretically, this can be improved

I don't see how. The ORDER BY ... LIMIT ... code is already optimised.

If there are NULLs in the left hand side then it needs to be treated as
unsorted, which forces a sort.

If you know there are no NULLs then don't do a FULL join.

--
Simon Riggs
2ndQuadrant http://www.2ndQuadrant.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2008-02-24 12:09:29 Re: Trigram performance penalty on varchar?
Previous Message Alban Hertroys 2008-02-24 11:37:26 Re: Regex query not using index