Re: Query optimization problem - Mailing list pgsql-hackers

From Dimitri Fontaine
Subject Re: Query optimization problem
Date
Msg-id 87wrsq9nz8.fsf@hi-media-techno.com
Whole thread Raw
In response to Re: Query optimization problem  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: Query optimization problem
List pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> All that having been said, I think the issue here is that the query
> planner isn't inferring that d1.ID=<some constant> implies d2.ID=<some
> constant>, even though there's a join clause d1.ID=d2.ID.

I think that's what the Equivalence Classes are for. Or at least that's
what they do in my head, not forcibly in the code.

The specific diff between the two queries is :
  JOIN DocPrimary d2 ON d2.BasedOn=d1.ID
- WHERE (d1.ID=234409763) or (d2.ID=234409763)
+ WHERE (d2.BasedOn=234409763) or (d2.ID=234409763)

So the OP would appreciate that the planner is able to consider applying
the restriction on d2.BasedOn rather than d1.ID given that d2.BasedOn is
the same thing as d1.ID, from the JOIN.

I have no idea if Equivalence Classes are where to look for this, and if
they're meant to extend up to there, and if that's something possible or
wise to implement, though.

Regards,
--
dim


pgsql-hackers by date:

Previous
From: Dave Page
Date:
Subject: Solaris Sparc - dblink regression test failure
Next
From: David Christensen
Date:
Subject: Re: Explicit psqlrc