使用即时文件初始化提高SQL Server性能

发表于:2015-7-29 09:37

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:Woodytu    来源:51Testing软件测试网采编

  如果SQL Server有执行卷维护任务(Performance Volume Maintenance Task)特权,从错误日志你可以看到,只有日志文件被填0初始化:
  Windows内核
  在SQL Server运行下服务帐号,你对它授予了执行卷维护任务(Performance Volume Maintenance Task)特权,在Windows操作系统内部会发生什么呢?启用这个特权后(它内部是通过WIN32 API调用所谓的SE_MANAGE_VOLUME_NAME函数),SQL Server可以调用SetFileValidData的WIN32 API函数。从在线文档里可以看到,调用那个函数的进程,有SE_MANAGE_VOLUME_NAME权限。当那个函数被SQL Server调用时,函数本身会设置文件所谓的High Watermark——在其NTFS簇里,文件直接扩展而不重写原始内容!正如在线文档所述:
  “The SetFileValidData function allows you to avoid filling data with zeros when writing nonsequentially to a file. The function makes the data in the file valid without writing to the file. As a result, although some performance gain may be realized, existing data on disk from previously existing files can inadvertently become available to unintended readers.”
  …
  “If SetFileValidData is used on a file, the potential performance gain is obtained by not filling the allocated clusters for the file with zeros. Therefore, reading from the file will return whatever the allocated clusters contain, potentially content from other users. This is not necessarily a security issue at this point, because the caller needs to have SE_MANAGE_VOLUME_NAME privilege for SetFileValidData to succeed, and all data on disk can be read by such users.”
  我已经说过,对于你的SQL Server实例,你是否启用这个权限主要是关系到安全的。
  小结
  对于你的SQL Server实例,你是否应该启用即时文件初始化?这个依具体情况而定……当你是SQL Server和系统管理员时,授予这个权限是个好主意,因为作为系统管理员,你总是可以访问文件系统的。但当你有专属的系统管理员和SQL Server管理员时,这就不可能授予了,因为系统管理员并不信任你,对于你的SQL Server实例你不会获得这个权限。那样的话SQL Server总会填0初始化数据和日志文件……
22/2<12
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号