不错呦!smile@林凯西,确保“准备文件”中的几个文件都有安装,S...您好,看了您这篇帖子觉得很有帮助。但是有个问题想请...我的修改过了怎么还被恶意注册呢 @jjjjiiii 用PJ快9年了,主要是A...PJ3啊,貌似很少有人用PJ了,现在不是WP就是z...@332347365,我当时接入时错误码没有-10...楼主,ChkValue值应为-103是什么意思呢?...大哥 你最近能看到我发的信息,请跟我联系,我有个制...
通过SQL Server2000执行计划查看索引的使用情况
编辑:dnawo 日期:2010-04-20
本文所有示例均在Student表上操作,表结构如下:
在Student表上建如下索引:

例1:select * from student

例2:select * from student where id<5

例3:select * from student where name like 'zhang%'

例4:select * from student where age>=18

例5:select * from student where name like 'zhang%' and age>=18

例6:select * from student where name like 'zhang%' and age>=18 and id<10

例7:select * from student where name like '%zhang%'

总结
·创建有用的索引很重要,它能大大提高查询的效率,如例2~例6;
·创建有效的查询语句很重要,它能保证尽可能的使用到索引[1],例7和例3就是最好的例子;
[1].要让查询尽可能使用到索引,就应在查询中尽量避免使用否定运算符,例如NOT、!=、<>、!>、!<、NOT EXISTS、NOT IN和NOT LIKE,避免对字段使用函数,例如:
引用内容
复制内容到剪贴板
程序代码

Create TABLE [dbo].[Student] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[name] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[age] [int] NULL
)
[id] [int] IDENTITY (1, 1) NOT NULL ,
[name] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[age] [int] NULL
)
在Student表上建如下索引:

例1:select * from student

例2:select * from student where id<5

例3:select * from student where name like 'zhang%'

例4:select * from student where age>=18

例5:select * from student where name like 'zhang%' and age>=18

例6:select * from student where name like 'zhang%' and age>=18 and id<10

例7:select * from student where name like '%zhang%'

总结
·创建有用的索引很重要,它能大大提高查询的效率,如例2~例6;
·创建有效的查询语句很重要,它能保证尽可能的使用到索引[1],例7和例3就是最好的例子;
[1].要让查询尽可能使用到索引,就应在查询中尽量避免使用否定运算符,例如NOT、!=、<>、!>、!<、NOT EXISTS、NOT IN和NOT LIKE,避免对字段使用函数,例如:

name like '%zhang%'
age<>15
abs(age)>=18
age<>15
abs(age)>=18
评论: 0 | 引用: 0 | 查看次数: 4890
发表评论
请登录后再发表评论!