Unix Technical Forum

Performing antijoin in postgres

This is a discussion on Performing antijoin in postgres within the pgsql Hackers forums, part of the PostgreSQL category; --> I want to add an antijoin operator to PostgreSql. Basically I want to store the result (tupletableslot) of one ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-15-2008, 09:45 PM
Suresh_
 
Posts: n/a
Default Performing antijoin in postgres


I want to add an antijoin operator to PostgreSql. Basically I want to store
the result (tupletableslot) of one join and then compare it with
another..How do I store these results and how do I compare them ?
--
View this message in context: http://www.nabble.com/Performing-ant...html#a12422596
Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-15-2008, 09:45 PM
Heikki Linnakangas
 
Posts: n/a
Default Re: Performing antijoin in postgres

Suresh_ wrote:
> I want to add an antijoin operator to PostgreSql. Basically I want to store
> the result (tupletableslot) of one join and then compare it with
> another..How do I store these results and how do I compare them ?


I would suggest implementing it at a higher level, rewriting a query
like "A ANTIJOIN B" to "A EXCEPT (A JOIN B)". That allows the planner to
use whatever methods it has to perform the EXCEPT and the JOIN
operations. At the moment there's only one method: sort the inputs and
do a merge, but it's conceivable that you could implement EXCEPT using
hashing, for example.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-15-2008, 09:45 PM
Gregory Stark
 
Posts: n/a
Default Re: Performing antijoin in postgres

"Suresh_" <suiyengar@yahoo.com> writes:

> I want to add an antijoin operator to PostgreSql.


I think you can already do what you want like this:

SELECT *
FROM A FULL OUTER JOIN B ON (x=y)
WHERE x IS NULL
OR y IS NULL

So for example:

postgres=# select * from a;
i
---
1
2
(2 rows)

postgres=# select * from b;
i
---
2
3
(2 rows)

postgres=# select * from a full outer join b on (a.i=b.i) where a.i is null or b.i is null;
i | i
---+---
1 |
| 3
(2 rows)

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-15-2008, 09:45 PM
Suresh_
 
Posts: n/a
Default Re: Performing antijoin in postgres



Thanks for the reply. I can do this at the higher level; but this antijoin
thing is a small part of a bigger project. So I want to do it internally in
one of the joins. Does anyone have experience in storing tupleslpts and
comparing them ??



Gregory Stark wrote:
>
> "Suresh_" <suiyengar@yahoo.com> writes:
>
>> I want to add an antijoin operator to PostgreSql.

>
> I think you can already do what you want like this:
>
> SELECT *
> FROM A FULL OUTER JOIN B ON (x=y)
> WHERE x IS NULL
> OR y IS NULL
>
> So for example:
>
> postgres=# select * from a;
> i
> ---
> 1
> 2
> (2 rows)
>
> postgres=# select * from b;
> i
> ---
> 2
> 3
> (2 rows)
>
> postgres=# select * from a full outer join b on (a.i=b.i) where a.i is
> null or b.i is null;
> i | i
> ---+---
> 1 |
> | 3
> (2 rows)
>
> --
> Gregory Stark
> EnterpriseDB http://www.enterprisedb.com
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>
>


--
View this message in context: http://www.nabble.com/Performing-ant...html#a12425655
Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.


---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:08 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com