Mysql function call

前端 未结 4 871
伪装坚强ぢ
伪装坚强ぢ 2021-02-10 04:34

If I call a function several time then will it execute every time or just execute once and the value will be used then after several time? Example:

 select my_fu         


        
4条回答
  •  再見小時候
    2021-02-10 05:24

    As far as I know (not a mysql pro) it is calling this function every time. Your expalin plan should show that issue.

    If you always call the function with the same argument, rather query it once per row via a sub-query.

    select funcvalue, funcvalue/field2, (funcvalue*field1)/field3,...... 
    from SELECT( my_function('filed') funcvalue, ... your other columns... 
    FROM TABLE )
    where group by filed1;
    

提交回复
热议问题