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

From Tom Lane
Subject Re: Avoiding sequential scans with OR join condition
Date
Msg-id 4234.1097943318@sss.pgh.pa.us
Whole thread Raw
In response to Avoiding sequential scans with OR join condition  (Mike Mascari <mascarm@mascari.com>)
List pgsql-general
Mike Mascari <mascarm@mascari.com> writes:
> SELECT big_table.*
> FROM little_table, big_table
> WHERE little_table.x = 10 AND
> little_table.y IN (big_table.y1, big_table.y2);

> Is there any way to write the first query such that indexes will be used?

I'm afraid you're stuck with the UNION workaround.  The planner's
treatment of OR indexscans is entirely separate from its treatment of
join indexscans, so it's just not capable of forming the sort of plan
you are envisioning.  It'd be nice to improve that someday, but it'd
take either a pile of duplicate code, or a fairly thorough rewrite
of indxpath.c/orindxpath.c.

            regards, tom lane

pgsql-general by date:

Previous
From: "Mark Dexter"
Date:
Subject: Re: Complex Update Queries with Fromlist
Next
From: Michael Fuhr
Date:
Subject: Re: plpgsql loop not returning value