select dbo.fun_1(col1) from tb where col2='xx' and dbo.fun_2(col3)='xxx'
如果col2上有索引:
那么次数是:
select count(*) from tb where col2='xx'
得到值为n即是说,过滤时,要调用n次。取结果时,还要n次,即为 2n次调用。
如果col2上无索引,则不能计算,因为无法确定 where过滤时过滤条件的先后。

解决方案 »

  1.   

    看错了,以为是同一个function如果col2有索引,
    fun_2被调用  select count(*) from tb where col2='xx'   次。fun_1被调用 select count(*) from tb where col2='xx' and dbo.fun_2(col3)='xxx' 次。如果col2无索引
    则不能计算fun_2调用次数,因为无法确定 where过滤时过滤条件的先后
    fun_1被调用 select count(*) from tb where col2='xx' and dbo.fun_2(col3)='xxx' 次。
      

  2.   

    fun_1:结果集有多少行,就会调用多少次。
    fun_2:select count(*) from tb where col2='xx' 有多少行,就会调用多少次。过滤的时候应该会先验证col2='xx'