Fanr

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2011年4月18日

摘要: Simple but accurate following script will give you list of all the indexes in the database which are unused. If indexes are not used they should be dropped as Indexes reduces the performance for INSERT/UPDATE statement. Indexes are only useful when used with SELECT statement.Script to find unused In 阅读全文
posted @ 2011-04-18 14:02 Fanr_Zh 阅读(407) 评论(0) 推荐(0) 编辑

2011年4月14日

摘要: USE AdventureWorks2008R2;GOCREATE PROCEDURE dbo.InsertUnitMeasure @UnitMeasureCode nchar(3), @Name nvarchar(25)AS BEGIN SET NOCOUNT ON;-- Update the row if it exists. UPDATE Production.UnitMeasure SET Name = @Name WHERE UnitMeasureCode = @UnitMeasureCode-- Insert the row if the UPDATE statement fail 阅读全文
posted @ 2011-04-14 14:52 Fanr_Zh 阅读(384) 评论(0) 推荐(0) 编辑

2011年4月10日

摘要: Establishing a Performance BaselineApplies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2Baseline performance monitoring involves establishing a performance baseline for your system. A performance baseline includes a single performance cha 阅读全文
posted @ 2011-04-10 16:27 Fanr_Zh 阅读(445) 评论(0) 推荐(0) 编辑

2011年4月9日

摘要: 背景: 磁盘空间不足原因: 日志文件过大,再次需要分配磁盘空间的时候,磁盘空间不足。业务停止,生产数据库瘫痪解决办法: dbcc shrinkfile(日志文件名,选项) 具体见联机手册结果: 删除磁盘不必要的空间,清空日志。解决当前状态 阅读全文
posted @ 2011-04-09 23:37 Fanr_Zh 阅读(493) 评论(0) 推荐(0) 编辑

摘要: Creating a Performance Baseline - Part 1You'll often hear that you should monitor the performance of SQL Server. You may read a little about performance monitoring, and you may turn on a few counters or perform a query against a dynamic management view that you know about. But, you may still won 阅读全文
posted @ 2011-04-09 14:04 Fanr_Zh 阅读(1070) 评论(0) 推荐(0) 编辑

2011年4月8日

摘要: 1.I/O 计数器:PhysicalDisk: Avg. Disk Queue Length 说明 :Avg. Disk Queue Length 指读取和写入请求(为所选磁盘在实例间隔中列队的)的平均数。 瓶颈 :如果在高峰使用的情况下,队列长度>2的话,,可能存在I/O瓶颈 计数器:PhysicalDisk: Avg. Disk Sec/Read Avg. Disk Sec/Write 说明:Avg. Disk sec/Read 指以秒计算的在此盘上读取数据的所需平均时间。 Avg. Disk sec/Write 指以秒计算的在此盘上写入数据的所需平均时间。 瓶颈:当读写的平均时间超 阅读全文
posted @ 2011-04-08 11:31 Fanr_Zh 阅读(1517) 评论(0) 推荐(0) 编辑

2011年4月7日

摘要: 计数器的说明可以在添加计数器那边资源对象\计数器建议的阈值注释磁盘Physical Disk\% Free SpaceLogical Disk\% Free Space15%磁盘Physical Disk\% Disk Time Logical Disk\% Disk Time90%磁盘Physical Disk\Disk Reads/sec、Physical Disk\Disk Writes/sec取决于制造商的规格检查磁盘的指定传送速度,以验证此速度没有超出规格。通常,Ultra Wide SCSI 磁盘每秒可以处理 50 到 70 次 I/O 操作。请注意,无论 I/O 是顺序的还是随机 阅读全文
posted @ 2011-04-07 16:50 Fanr_Zh 阅读(1108) 评论(0) 推荐(0) 编辑

摘要: 背景: 在900W 的表上加 identity 字段原因: 企业管理器一直无法应用,cpu占用100% 关闭企业管理器之后,导致数据库无法访问 重启数据库服务,数据库服务只能关闭无法重启结果: 重启服务器结论: 不要在界面上修改结构,特别是企业管理器,会带来很多不要的处理 阅读全文
posted @ 2011-04-07 16:09 Fanr_Zh 阅读(318) 评论(0) 推荐(0) 编辑

摘要: 背景: 因为要更换服务器,需要把原先的数据库备份到新服务器上,但是业务不能停太长的时间。就写了一个作业,没有以为没有问题也就没有试着运行只检查了语法。问题: 作业时凌晨4的开始,今天上班,却发现作业报错了,原因就是需要备份的数据库名拼错了。解决办法: 放到明天继续备份。总结: 一定要检查好你所操作的东西是有用的。环境最好能够测试一下,生成数据库容不得一点马虎。 阅读全文
posted @ 2011-04-07 10:13 Fanr_Zh 阅读(251) 评论(0) 推荐(0) 编辑

2011年4月6日

摘要: 问题: 因为做了数据库可用性扩展,导致业务出现问题原因: 数据库做了订阅发布,事务性的请求订阅,在做之前不清楚,应用层会有TRUNCATE Table 的操作导致。发布数据库的时候把原本要 TRUNCATE 的表也发布进去了。导致应用成在TRUNCATE Table 的时候报错。表数据无法被清空,因为业务的关系导致重复数据库暴增,并且数据量暴增。结论: 1.DBA 不止要关心数据库的日志,系统的日志,也要关心一下应用层的日志。 2.在做提高数据库可用性之前,应该先询问开发人员时候会有不写入日志的操作。 3.在更改了数据库之后,要特别注意这两天的数据库日志,系统日志,和应用程序日志。结局: 为了 阅读全文
posted @ 2011-04-06 19:02 Fanr_Zh 阅读(286) 评论(0) 推荐(0) 编辑

摘要: 基本参考: http://www.99inf.net/DB/SqlServer/223.htm里面的内容很全。有以下几点需要提前做的。 用来放置主服务器的日志备份的文件夹我们就叫 logfile 错误:无法访问 logfile 原因:没有设置共享的权限 解决办法:logfile 里面只是设置了安全里面的权限是不够的,要需要设置共享里面的权限 错误:错误代码 14261 指定的 primary_server_name.primary_database_name('S')已经存在。 原因:因为你是第二次设置日志发送,因为第一次的残留没有被sql server回滚,这个是sql se 阅读全文
posted @ 2011-04-06 16:04 Fanr_Zh 阅读(351) 评论(0) 推荐(0) 编辑

2011年4月2日

摘要: There are several new features in SQL Server 2005. There are a few features to help find missing indexes, which are some of the very good ones. How great it will be if you know what indexes you need to create based on your workload? In SQL Server 2000, we had to use SQL Profiler trace files and Inde 阅读全文
posted @ 2011-04-02 12:45 Fanr_Zh 阅读(471) 评论(0) 推荐(0) 编辑

2011年4月1日

摘要: I have a client that was in need of moving all there indexes from the primary file group to an index file group. There were a total of 25 databases so the time needed to script each one individually would have been overwhelming not to mention the need to perform this across multiple environments.I s 阅读全文
posted @ 2011-04-01 13:46 Fanr_Zh 阅读(328) 评论(0) 推荐(0) 编辑

摘要: Introductionsp_who2 is a well known utility that shows what spids are currently executing. However the information it shows is relatively limited. For example, it only shows the type of command executing as SELECT, DELETE etc, with no reference to the actual underlying SQL executing.Knowing what SQL 阅读全文
posted @ 2011-04-01 12:50 Fanr_Zh 阅读(1172) 评论(0) 推荐(0) 编辑

2011年3月31日

摘要: Below is what is collectedShows SQL Servers information Shows top 5 high cpu used statemants Shows who so logged in Shows long running cursors Shows idle sessions that have open transactions Shows free space in tempdb database Shows total disk allocated to tempdb database Show active jobs Shows clie 阅读全文
posted @ 2011-03-31 14:14 Fanr_Zh 阅读(518) 评论(0) 推荐(0) 编辑

摘要: SQL Server 2005 Logon Triggers by Frederik Vandeputte as SSCLogon triggers by Cristian Lefter as Simple-talk 阅读全文
posted @ 2011-03-31 10:07 Fanr_Zh 阅读(315) 评论(0) 推荐(0) 编辑

摘要: 当用户使用的连接如果是可串行的隔离级别 logon trigger 就会报错原文下载 The Best of SQLServerCentral.com, Vol.7The Best of SQLServerCentral.com, Vol.7 阅读全文
posted @ 2011-03-31 09:32 Fanr_Zh 阅读(243) 评论(0) 推荐(0) 编辑

2011年3月30日

摘要: Exec sp_droplinkedsrvlogin DBVIP,NullExec sp_dropserver DBVIPEXEC sp_addlinkedserver @server='DBVIP',--被访问的服务器别名 @srvproduct='', @provider='SQLOLEDB', @datasrc='Server2' --要访问的服务器EXEC sp_addlinkedsrvlogin 'DBVIP', --被访问的服务器别名 'false', NULL, 'sa' 阅读全文
posted @ 2011-03-30 14:33 Fanr_Zh 阅读(383) 评论(0) 推荐(0) 编辑

摘要: Make sure each maintenance job has an output file in a standarddirectory.In the advanced tab under the job steps create an output file. This willallow you to see the full description of the job execution. There isnothing more annoying than not being able to see why a job failed.如何设置作业输出文档:In Object 阅读全文
posted @ 2011-03-30 11:10 Fanr_Zh 阅读(187) 评论(0) 推荐(0) 编辑

摘要: You may find yourself in a position where you need to look at what jobs have been running over a specifiedperiod of time. SQL Server has a stored procedure sphelpjob that will allow you to look at the jobs and what their status is currently, but maybe you need to do some additional processing like s 阅读全文
posted @ 2011-03-30 10:40 Fanr_Zh 阅读(1202) 评论(0) 推荐(0) 编辑

摘要: Whenever SQL Server is restarted, it creates a new error log. If theserver stays up for a while, this can make for a very large error log. I create a job that runs on a daily or weekly basis that executes the sp_cycle_errorlog stored procedure in the master database. This will create a new error lo. 阅读全文
posted @ 2011-03-30 10:13 Fanr_Zh 阅读(290) 评论(0) 推荐(0) 编辑

摘要: This script permit executes the sp_updatestats in all databases at same time.First I create the stored procedure above in an admin database, for sample I create one database with ADMIN name where I put all administration objects create for me. You can create this sp in exist db, if you want.Now you 阅读全文
posted @ 2011-03-30 09:38 Fanr_Zh 阅读(2281) 评论(0) 推荐(0) 编辑

2011年3月29日

摘要: 问题: 有一个库, 做的是 全备份+日志备份,在2011年3月8日,14点产生一次全备份,在14:10分产生日志备份,在14:12分down 机,请问 怎么能恢复 14:10 到 14:12分中的这段数据(前提,前期日志备份全部正确可用),机器硬盘完好。使用方法: 1.如果数据库已经损坏 如果数据库已经损坏,可以使用 backup log {数据库名} to {磁盘逻辑地址} with no_truncate 备份数据库。 因为可能存在对受损数据库备份日志尾部时,日志备份中正常捕获的部分元数据可能不可用。 尾日志备份可捕获日志尾部,即使数据库离线、损坏或缺少数据文件。 这可能导致还原信息命令和 阅读全文
posted @ 2011-03-29 14:07 Fanr_Zh 阅读(628) 评论(0) 推荐(0) 编辑

2011年3月28日

摘要: 优化数据库快照(一)优化数据库快照(二) 阅读全文
posted @ 2011-03-28 16:44 Fanr_Zh 阅读(277) 评论(0) 推荐(0) 编辑

摘要: 以下是一些sql server的DBCC命令,可以在优化 sql server时使用。1. DBCC CacheStats:显示存在于当前 buffer Cache 中的对象的信息,例如 :hit rates,编译的对象和执行计划例:DBCC CACHESTATS执行结果(缩略)Object Name Hit Ratio-------------------------Proc0.86420054765378507Prepared0.99988494930394334Adhoc 0.93237136647793051ReplProc0.0Trigger 0.99843452831887947C 阅读全文
posted @ 2011-03-28 16:29 Fanr_Zh 阅读(298) 评论(0) 推荐(0) 编辑