Sailesh Krishnamurthy <[EMAIL PROTECTED]> writes:
> I like the idea of memoizing the switch with function pointers as I
> don't think branch prediction helps much with varying switch arms
> selected with different exprs.

Check, it's hard to see how any CPU could get much traction on the
behavior of the switch jump in ExecEvalExpr.

> I've forgotten the syntax of case, but for the simple form isn't
> expr=const going to be the same expr for each case arm ? If that's the
> case, couldn't we actually save the value of expr in a Datum and then
> reuse that (through a Const) in each of the other arms to evaluate the
> actual exprs ? That should reduce the number of times ExecEvalVar (and
> through it heapgetattr) are called. 

Right now we expand the simple form of CASE into the general form:
        CASE x WHEN y THEN ... WHEN z THEN ...
becomes
        CASE WHEN x=y THEN ... WHEN x=z THEN ...
This does involve multiple evaluation of x, which'd be particularly
nasty if it's more than just a variable reference.  It's probably a good
idea to try to improve that.  But inlining ExecEvalExpr will help all
expressions not just CASE, so I'll work on that first ...

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to