On Thu, 2005-10-06 at 09:38 -0400, Tom Lane wrote:
> Simon Riggs <simon@2ndquadrant.com> writes:
> > It might be worth teaching the optimiser that if it has an index on an
> > immutable function that if we have WHERE x = k and a functional index on
> > f(x) then we can access the functional index with
> > f(x) = f(k), as long as we also reapply the original WHERE clause.
>
> As I just pointed out to Gaetano, this is utterly wrong. We can't
> assume that much about the behavior of equality.
For any function, yes, because you can always construct a function that
violates that. But it seems straightforward to introduce another
declarative form for which it is true, similar to the way that IMMUTABLE
allows us to make other assumptions at parse time. That's only worth it
if you believe that many useful functions follow that rule; I would say
that they do.
Best Regards, Simon Riggs