随笔分类 -  SqlServer

查看索引使用情况
摘要:索引使用统计数据 阅读全文

posted @ 2011-12-28 11:07 zhengcong 阅读(335) 评论(0) 推荐(0)

查看SqlServer数据页元数据
摘要:查看表或索引的元数据,查看单个表数据页使用情况,查看单个数据页数据 阅读全文

posted @ 2011-12-22 16:24 zhengcong 阅读(968) 评论(0) 推荐(0)

不同主键设置对查询性能的影响分析
摘要:两张表字段一样,数据量一样,不同在于主键的设置上。一个ProjectID对应多个TicketNo,TicketNo唯一,任意字母和数字的组合。主要的频率很高的查询类似:select * from dbo.EmptyTicket where projectid = 243 and statuscode = 0执行如下语句set statistics io onset statistics time onset statistics profile onselect * from dbo.EmptyTicket where projectid = 243 and statuscode = 0sel 阅读全文

posted @ 2011-09-05 17:57 zhengcong 阅读(1413) 评论(0) 推荐(0)

多值字符窜参数的处理
摘要:--外部参数declare@hotelIDsnvarchar(4000)set@hotelIDs='1,2,3,4,5,6,7,8,9,'--内部参数declare@hotelidnvarchar(8),@lengthint,@indexintcreatetable#tmp(idnvarchar(8));set@length=len(@hotelIDs)-len(replace(@hotelIDs,',',''));set@index=1;while@index<=@lengthbeginset@hotelid='';set 阅读全文

posted @ 2011-08-23 11:09 zhengcong 阅读(246) 评论(0) 推荐(0)

sqlserver 各种Join区别
摘要:介绍Inner Join, Full Out Join,Cross Join,Left Join, Right Join区别。--创建测试表--------------------------------------------------------------create table Customers (Cust_Id int, Cust_Name varchar(10))insert Customers values (1, 'Craig')insert Customers values (2, 'John Doe')insert Customers v 阅读全文

posted @ 2011-07-28 11:12 zhengcong 阅读(18292) 评论(0) 推荐(6)

【工具脚本】--查询阻塞的执行脚本
摘要:selectmaster.dbo.sysprocesses.spid,master.[dbo].sysprocesses.[sid],master.dbo.sysprocesses.status,b.[Individual Query],master.dbo.sysprocesses.cpu,master.dbo.sysprocesses.physical_io,master.dbo.sysprocesses.hostname,master.dbo.sysprocesses.program_name,master.dbo.sysprocesses.cmd ,master.dbo.sysproc 阅读全文

posted @ 2010-12-14 14:28 zhengcong

索引维护
摘要:【摘要】: 基础知识 sqlserver最基本的数据存储单元是data page,大小为8K,一次分配8个连续的page,称为extent。 数据页和索引页都是会发生split page动作,在插入或修改数据引起页剩余空间不足时发生。会将插入位置后的数据移走,移动到新的数据也上。 下图示例索引刚刚建立好之后逻辑上是连续时的索引结构: 假如此时需要插入索引值为2的新索引,则插入之后的索引结构如下图: DBCC SHOWCONTIG (TblUserItem,PK_TblUserItem) --显示表TblUserItem中索引PK_TblUserItem的fragment... 阅读全文

posted @ 2010-12-10 14:01 zhengcong