51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 2941|回复: 1
打印 上一主题 下一主题

sybase的索引查询时使用了is null,索引仍有效?

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2012-7-4 13:53:57 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
在网上看了很多资料,都说在索引列使用is null或则is not null,索引会失效,但是今天自己试了一下,发现:

Select a.Circuit_Id,a.State_Name ,a.Status from tCircuit a  
where a.Spec_Id = 3 and a.Service_Number is null---这句会使用Service_Number 上的索引

Select a.Circuit_Id,a.State_Name ,a.Status from tCircuit a  
where a.Spec_Id = 3 and a.Service_Number is not null ----这句不会使用Service_Number上的索引,会使用表扫描

Select a.Circuit_Id,a.State_Name ,a.Status from tCircuit a  
where a.Spec_Id = 3 and a.Service_Number is not null and a.Service_Number like 'LDC%' --这句会使用Service_Number 上的索引

以下例子中,C1列有索引,c2列无索引:
select t1.c1 from t1  where  t1.c1 is   null使用了c1的索引
select t1.c1,c2 from t1  where  t1.c1 is  null 使用了c1的索引
select t1.c1,c2 from t1  where  t1.c1 is not  null,使用表扫描
select t1.c1 from t1  where  t1.c1 is not  null 使用索引

这个要怎么理解呢?我完全糊涂了:-( ,还请各位高人指教
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

  • TA的每日心情
    奋斗
    2022-5-8 19:23
  • 签到天数: 137 天

    连续签到: 1 天

    [LV.7]测试师长

    2#
    发表于 2012-8-7 21:37:14 | 只看该作者
    没用过sybase
    回复 支持 反对

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-9-22 12:45 , Processed in 0.079779 second(s), 28 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表