首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

这条查询的SQL语句应该如何优化才能速度更快?求高手解答

2012-01-09 
这条查询的SQL语句应该怎么优化才能速度更快?求高手解答!selectFieldContentfromQBS_SHOPInfo_ntextwhere

这条查询的SQL语句应该怎么优化才能速度更快?求高手解答!
"select   FieldContent   from   QBS_SHOPInfo_ntext   where   shopID= "&shopID& "   and   (FieldName= 'shopIntro '   or   FieldName= 'ServiceSDD '   or   FieldName= 'ZiZhi '   or   FieldName= 'BuildCharacteristic '   or   FieldName= 'ServicePrice '   or   FieldName= 'DesignSDD '   or   FieldName= 'zuixincuxiao '   or   FieldName= 'ServiceProcess ') "

[解决办法]
加索引
[解决办法]
shopID,FieldName加索引试试
[解决办法]
不要這樣寫吧


"select FieldContent from QBS_SHOPInfo_ntext where shopID= "&shopID& " and (FieldName in( 'shopIntro ', 'ServiceSDD ', 'ZiZhi ' , 'BuildCharacteristic ' , 'ServicePrice ', 'DesignSDD ' , 'zuixincuxiao ', 'ServiceProcess ')) "

[解决办法]
對shopID加索引
[解决办法]
create NONCLUSTERED index index_name
on tablename
(shopID,FieldName)
[解决办法]
不要這樣寫吧


"select FieldContent from QBS_SHOPInfo_ntext where shopID= "&shopID& " and (FieldName in( 'shopIntro ', 'ServiceSDD ', 'ZiZhi ' , 'BuildCharacteristic ' , 'ServicePrice ', 'DesignSDD ' , 'zuixincuxiao ', 'ServiceProcess ')) "
___________________________________________________________________________________

这样与原来的那样执行效率一样
[解决办法]
select FieldContent from QBS_SHOPInfo_ntext a inner join
(select 'shopIntro ' FieldName
union all
select 'ServiceSDD '
....
union all
select 'ServiceProcess '
) as b on a.FieldName=b.FieldName where shopID= "&shopID& "
[解决办法]
没什么问题加索引

热点排行