sql server 表别名性能低 临时表性能高
看以下例子:
?
写了一个存储过程对视图进行分页查询,但数据增多后发现基效率低得要命,三万多条数据要查询一个半小时都没出来,这不是要了命,于是想到了索引,应用过后仍无济于事。最后对sql进行分析和实践中得出,使用临时表可以大大加快视图的查询速度,见如下sql语句 性能超低的视图分页sql语句:select top 100 * from view_customerPayDetails where ( 1=1) and (payId not in(select top 100 payId from view_customerPayDetails where ( 1=1) order by payId desc))order by payId desc使用临时表提升性能的sql语句:select top 100 payId into #tmpTable from view_customerPayDetailsorder by payId descselect top 100 * from view_customerPayDetails where payId not in (select payId from #tmpTable ) order by payId descdrop table #tmpTable ......?
?
?
REF URL:http://www.ej38.com/showinfo/sqlserver-141034.html
?
?
?
?
?
?