sql 索引 速度慢

carson159 2017-04-05 11:03:25
certIndfo表,有一列certNo 建立有索引,执行select certNo from certIndfo where 1=1 and certNo='123456789' 查询速度正常(几十毫秒),select certNo from certIndfo where 1=1 and certNo='123456789' and certName='myname' 速度非常慢(certName没有索引),两百万的数据用了一分钟的时间,求大神解释问题所在 。数据库用的是Sybase
...全文
211 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
吉普赛的歌 2017-04-13
  • 打赏
  • 举报
回复
方法一:如楼上所说, 创建复合索引。 方法二:
select certNo from  
(select certNo,certName from certIndfo where 1=1 and certNo='123456789')
AS t 
where 1=1 and certName='myname'
LongRui888 2017-04-13
  • 打赏
  • 举报
回复
可以再创建一个索引,也可以创建一个联合索引: (certNo,certName)
  • 打赏
  • 举报
回复
certName加索引试试

22,298

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧