On Mon, Jun 13, 2005 at 09:51:57 -0500,
John A Meinel <john@arbash-meinel.com> wrote:
>
> I don't know if there are specific reasons why not, other than just not
> being implemented yet. It might be tricky to get it correct (for
> instance, how do you know which columns can be added, which ones will be
> constant) Perhaps you could just potentially add the WHERE items if they
> have an equality constraint with a constant. But I'm guessing there are
> more cases than that where the optimization could be performed.
I think there is already some intelligence about which expressions are
constant in particular parts of a plan.
I think you need to be able to do two things. One is to drop constant
expressions from order by lists. The other is when looking for an index
to produce a specific ordering, to ingore leading constant expressions
when comparing to the order by expressions.
> Also, the more options you give the planner, the longer it takes on
> average to plan any single query. Yes, it is beneficial for this use
> case, but does that balance out slowing down all the other queries by a
> tiny bit.
But there aren't that many possible indexes, so I don't expect this will
slow things down much more than the current check for potentially useful
indexes.