Skip site navigation (1) Skip section navigation (2)

Re: FULL JOIN and mergjoinable conditions...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Postgresql General <pgsql-general(at)postgresql(dot)org>
Subject: Re: FULL JOIN and mergjoinable conditions...
Date: 2004-06-30 05:20:23
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
> Today I got the error:
> ERROR:  FULL JOIN is only supported with mergejoinable join conditions
> Which is really annoying since a full join is exactly what I wanted. I
> guess the alternative is to do a left join and a right join and merge
> them? Is it just that no-one has come up with a way to code this
> efficiently?

How would you do it?  It seems fairly impractical with an underlying
nestloop join --- you'd need persistent state for *every* row of the
inner relation to show whether any outer row had matched it.

You could imagine doing it with a hash join (mark every hash table entry
when it gets visited by an outer-row hash probe, then traverse the hash
table at the end to emit unvisited rows).  But a quick look into
pg_operator convinces me that this would be pointless to implement,
because we have no interesting datatypes that support hash join but not
mergejoin.  And hashjoins are only practical with relatively-small inner
relations anyway.  Not to mention that hashjoin isn't any more amenable
to inequality join conditions than mergejoin is...

			regards, tom lane

In response to

pgsql-general by date

Next:From: Joe ConwayDate: 2004-06-30 05:26:07
Subject: Re: minimum operators for b-tree, r-tree
Previous:From: eleinDate: 2004-06-30 05:03:09
Subject: minimum operators for b-tree, r-tree

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group