语句增加order by后由查询零秒变为了15秒,求解
查询语句如下:
这是带order by语句的
declare @d datetime set @d=getdate();with cte as(select SZ_QStandType.QStandTypeID,SZ_QStandType.QStandTypeName from SZ_QStand inner join containstable(SZ_QStand,(QStandFRContent,QStandGRContent),'(" 测量")',500)as k on QStandID=k.[key] inner join SZ_QStandType on SZ_QStand.QStandTypeID=SZ_QStandType.QStandTypeID)select * from (select distinct top 1000 * from cte order by QStandTypeID asc)t;select [语句执行花费时间(毫秒)]=datediff(ms,@d,getdate())
declare @d datetime set @d=getdate();with cte as(select SZ_QStandType.QStandTypeID,SZ_QStandType.QStandTypeName from SZ_QStand inner join containstable(SZ_QStand,(QStandFRContent,QStandGRContent),'(" 测量")',1000)as k on QStandID=k.[key] inner join SZ_QStandType on SZ_QStand.QStandTypeID=SZ_QStandType.QStandTypeID)select * from (select top 1000 * from cte )t;select [语句执行花费时间(毫秒)]=datediff(ms,@d,getdate())