Re: inner join is much faster! is that right? - Mailing list pgsql-sql

From James Im
Subject Re: inner join is much faster! is that right?
Date
Msg-id BAY7-F27352E5152460F67D8E96896220@phx.gbl
Whole thread Raw
In response to inner join is much faster! is that right?  ("James Im" <im-james@hotmail.com>)
List pgsql-sql
I was doing the explain thing when I discovered my mistake!

The think is that I over simplyfied my examples. instead of searching
for one ID, I was searching for several ids and I forgot to put a
parentesis arround the or like this.

I was doing this:
select *
from file a, file_tag b, tag c
where a.id_file=b.id_file and b.id_tag=c.id_tag and
a.id_file=10000001000000 or a.id_file=10000001000200

But I should have done this:

select *
from file a, file_tag b, tag c
where a.id_file=b.id_file and b.id_tag=c.id_tag and
(a.id_file=10000001000000 or a.id_file=10000001000200)

This changes everything. The performance is now acceptable!

_________________________________________________________________
V�lg selv hvordan du vil kommunikere - skrift, tale, video eller billeder 
med MSN Messenger:  http://messenger.msn.dk/  - her kan du det hele



pgsql-sql by date:

Previous
From: Chris Mair
Date:
Subject: Re: inner join is much faster! is that right?
Next
From: CG
Date:
Subject: Nested loops are killing throughput