请问各位,如下两种写法查询速度一样吗?select *
from a with(nolock) inner join b on b.id = a.id
where a.ss = 0
select *
from a ,b 
where a.id = b.id 
      and a.ss = 0

解决方案 »

  1.   


    select * from a inner join b on b.id = a.id where a.ss = 0 
    select * from a ,b where a.id = b.id and a.ss = 0 
    --速度基本相同
      

  2.   

    写个存储过程,你可以测试一下/************************************************/
    /*<summary>计算sql语句的执行时间</summary>*******/
    /*<name>:m_delrepeatsplit</name>*****************/
    /*author:maco_wang*******************************/
    /*createtime:2008-12-31**************************/
    /*<param name="@sql">要执行的sql语句</param>*****/
    /************************************************/
    create proc [dbo].[get_exec_time]( @sql nvarchar(4000))
    as
    begin 
    declare @begintime datetime
    set @begintime= getdate(); --begin exec
    exec(@sql)

    --end exec declare @t int
    select @t=
    datediff(ms,@begintime,getdate()) select 
    cast(@t/3600000 as nvarchar(200))  +' 时'+
    cast(@t/60000%60 as nvarchar(200))+' 分'+
    cast(@t/1000%60 as nvarchar(200)) +' 秒'+
    cast(@t%1000 as nvarchar(200)) + ' 毫秒' '运行时间'
    end/*test
    exec get_exec_time
     'declare @i int 
      set @i=0;
      while @i<1000000
      begin
         set @i=@i+1;
      end'
    */
      

  3.   

    速度相同,select * from a inner join b on b.id = a.id where a.ss = 0 
    select * from a ,b where a.id = b.id and a.ss = 0