Re: Index isn't used during a join.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Creager <Robert_Creager(at)LogicalChaos(dot)org>
Cc: Michael Fuhr <mike(at)fuhr(dot)org>, PGPerformance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Index isn't used during a join.
Date: 2006-01-11 15:33:03
Message-ID: 12877.1136993583@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Robert Creager <Robert_Creager(at)LogicalChaos(dot)org> writes:
> What I had thought is that PG would (could?) be smart enough to realize tha=
> t one query was restricted, and apply that restriction to the other based o=
> n the join. I know it works in other cases (using indexes on both tables u=
> sing the join)...

The planner understands about transitivity of equality, ie given a = b
and b = c it can infer a = c. It doesn't do any such thing for
inequalities though, nor does it deduce f(a) = f(b) for arbitrary
functions f. The addition Michael suggested requires much more
understanding of the properties of the functions in your query than
I think would be reasonable to put into the planner.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2006-01-11 15:45:47 Re: Slow query with joins
Previous Message Pallav Kalva 2006-01-11 15:27:39 Postgres8.0 planner chooses WRONG plan