Re: Avoiding sequential scans with OR join condition - Mailing list pgsql-general

From Mike Mascari
Subject Re: Avoiding sequential scans with OR join condition
Date
Msg-id 4172193D.8030202@mascari.com
Whole thread Raw
In response to Re: Avoiding sequential scans with OR join condition  (Sim Zacks <sim@compulab.co.il>)
Responses Re: Avoiding sequential scans with OR join condition  (Mike Mascari <mascarm@mascari.com>)
List pgsql-general
Sim Zacks wrote:
> I would use 2 left joins and use the where condition to make sure one
> of them is true, such as:
>
> select big_table.* from
> big_table left join little_table as l1 on big_table.y1=l1.y and
> l1.x=10
> left join little_table as l2 on big_table.y2=l2.y and l1.x=10
> where l1.p_key is not null and l2.p_key is not null
>
> I have never tried this in postgresql, but in my experience with
> various other DB engines it is a lot faster then using an or in the
> join and faster then a union.

Wow! Thanks! That certainly did the trick.

Mike Mascari

pgsql-general by date:

Previous
From: Sim Zacks
Date:
Subject: Re: Avoiding sequential scans with OR join condition
Next
From: Mike Mascari
Date:
Subject: Re: Avoiding sequential scans with OR join condition