{"id":301886,"date":"2020-04-14T21:00:38","date_gmt":"2020-04-14T21:00:38","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=301886"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=301886","title":{"rendered":"\u0417\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u0440\u0443\u0436\u0438\u0442\u044c SQL server \u0438 PerfMon"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/497238\/\">\u041d\u0430 \u0444\u043e\u0442\u043e \u0441\u0446\u0435\u043d\u0430 \u0438\u0437 \u0441\u0442\u0430\u0440\u043e\u0439 \u0434\u043e\u0431\u0440\u043e\u0439 \u043a\u043e\u043c\u0435\u0434\u0438\u0438 \u00ab\u0410\u044d\u0440\u043e\u043f\u043b\u0430\u043d\u00bb \u2014 \u0431\u0443\u043c\u0435\u0440\u044b \u043f\u043e\u043c\u043d\u044f\u0442 \u0435\u0435. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ln\/if\/dn\/lnifdnnc4rrtbmkaivipqr0gbks.jpeg\"><\/p>\n<p>  \u041e\u043d\u0430 \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e. \u041d\u043e \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h3>DBA \u043d\u0435 \u043b\u044e\u0431\u044f\u0442 perfmon<\/h3>\n<p>  \u0412\u043e\u0432\u0441\u0435 \u043d\u0435 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 PerfMon \u043d\u0435 \u043c\u0435\u043d\u044f\u043b\u0441\u044f \u0441 Windows NT 3.1 (?) \u0438 \u043e\u0442\u0434\u0430\u0435\u0442 \u0442\u0435\u043f\u043b\u043e\u0439 \u043b\u0430\u043c\u043f\u043e\u0432\u043e\u0441\u0442\u044c\u044e \u0434\u0432\u0443\u0445\u0442\u044b\u0441\u044f\u0447\u043d\u044b\u0445 \u0433\u043e\u0434\u043e\u0432. \u041a\u0441\u0442\u0430\u0442\u0438, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0442\u043e \u043d\u0438\u0431\u0443\u0434\u044c \u0437\u043d\u0430\u0435\u0442 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u043c\u0443 \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u043c\u0443 \u0444\u0430\u043a\u0442\u0443. Control panel \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0432 \u0433\u043e\u0434. \u0414\u0430\u0436\u0435 \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u043b\u0438. \u041d\u043e \u043d\u0435 perfMon. <\/p>\n<p>  DBA \u043c\u044b\u0441\u043b\u0438\u0442 \u043a\u0432\u0435\u0440\u044f\u043c\u0438. \u041a\u043e\u0433\u0434\u0430 \u043a \u0431\u043e\u043b\u044c\u043d\u043e\u043c\u0443 SQL server \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0434\u043e\u0431\u0440\u044b\u0439 \u0434\u043e\u043a\u0442\u043e\u0440 DBA, \u043e\u043d \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0441\u0432\u043e\u0439 \u0447\u0435\u043c\u043e\u0434\u0430\u043d\u0447\u0438\u043a, \u0430 \u0432 \u0447\u0435\u043c\u043e\u0434\u0430\u043d\u0447\u0438\u043a\u0435 \u044d\u0442\u043e\u043c \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0432\u0435\u0440\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043b\u0443\u0436\u0430\u0442 \u0435\u043c\u0443 \u0432\u0435\u0440\u043e\u0439 \u0438 \u043f\u0440\u0430\u0432\u0434\u043e\u0439. \u0421\u0430\u043c\u044b\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u0438\u0437 \u043d\u0438\u0445 \u043e\u043d \u043d\u0430\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438. \u0418\u043d\u043e\u0433\u0434\u0430 DBA \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0438 \u0432 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 PerfMon \u2014 Physical disk, \u0438\u043b\u0438 Disk Queue Length. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0436\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 SQL server \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 DBA \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 PerfMon, \u0430 \u0442\u043e\u0436\u0435 \u043a\u0432\u0435\u0440\u044c\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a:<\/p>\n<pre><code class=\"sql\">select * from sys.dm_os_performance_counters    where object_name='SQLServer:Buffer Manager'      and counter_name like 'Page life expectancy%'  \tand instance_name='' <\/code><\/pre>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u0438 IT, \u043e\u0442\u043e\u0440\u0432\u0430\u043d\u043d\u044b\u0435 \u043e\u0442 DBA \u0441\u0444\u0435\u0440\u044b, \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u044e\u0442 \u0435\u0433\u043e, \u00ab\u043a\u0430\u043a\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0438?\u00bb (\u043d\u0443 \u0442\u0430\u043c \u0432\u0441\u044f\u043a\u0438\u0435 splunk, squared-up \u0438\u0442\u0434), \u0442\u043e DBA \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0434\u0443\u043c\u0430\u0442\u044c \u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u0445, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u2014 \u043e perfmon metrics. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0441\u0442\u0430\u0440\u0430\u044e\u0442\u0441\u044f \u0432\u044b\u0432\u0430\u043b\u0438\u0442\u044c \u043d\u0430 DBA \u0432\u0441\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438. \u041a\u043e\u0433\u0434\u0430 \u0442\u0430\u043a\u043e\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u043f\u043e \u0441\u0432\u043e\u0435\u0439 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043a\u0430\u0440\u0442\u0438\u043d\u0430. \u0418 \u0442\u0443\u0442 \u0443\u0436\u0435 \u043c\u043d\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 <a href=\"https:\/\/www.youtube.com\/watch?v=LyUN40weqIk\" rel=\"nofollow\">\u0432\u0438\u0434\u0435\u043e \u043e\u0442\u0440\u044b\u0432\u043e\u043a \u0438\u0437 \u0444\u0438\u043b\u044c\u043c\u0430 \u00ab\u0410\u044d\u0440\u043e\u043f\u043b\u0430\u043d\u00bb<\/a>.<\/p>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 DBA \u043f\u0438\u0448\u0435\u0442 \u043a\u0432\u0435\u0440\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043a\u0430\u0436\u0434\u044b\u0435 N \u043c\u0438\u043d\u0443\u0442 \u0432 \u043a\u0430\u043a\u0443\u044e-\u043d\u0438\u0431\u0443\u0434\u044c \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0443 \u0432 \u0431\u0430\u0437\u0435 DBAtasks. \u0423\u0437\u043d\u0430\u0435\u0442\u0435 \u0441\u0435\u0431\u044f?<\/p>\n<h3>\u0412\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u0430\u0434\u0432\u043e\u043a\u0430\u0442\u043e\u043c \u0434\u044c\u044f\u0432\u043e\u043b\u0430 (perfmon)<\/h3>\n<p>  \u0418 \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, perfmon counters \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c. \u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u043b\u043e\u0433\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0430\u043b\u0435\u0440\u0442\u044b, \u043d\u043e \u0441\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0435\u0441\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441\u0438\u0441\u0442\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u00ab\u0441\u043b\u0438\u0432\u0430\u044e\u0442\u00bb \u044d\u0442\u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0441\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u043c\u0430\u0448\u0438\u043d \u0432 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u043f\u043e \u043d\u0438\u043c \u0430\u043d\u0430\u043b\u0438\u0437 \u0438 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0435 (\u0430 \u043d\u0435 \u043a\u0430\u043a \u0432 perfmon) \u0433\u0440\u0430\u0444\u0438\u043a\u0438. <\/p>\n<p>  \u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0434\u0440\u0443\u0436\u0438\u0442\u044c SQL world \u0438 PerfMon world! <\/p>\n<p>  \u041d\u0438\u0436\u0435 \u044f \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a.<\/p>\n<h3>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u0438\u043a\u0430<\/h3>\n<p>  \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u044b \u043f\u043e\u043a\u0430\u0436\u0435\u043c, \u043a\u0430\u043a \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 PerfMon \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442 \u0441\u0430\u043c SQL. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"sql\">select   convert(numeric(10,2),round(((sum(version_store_reserved_page_count)*1.0)\/128.00),2)),   convert(numeric(10,2),round(((sum(user_object_reserved_page_count)*1.0)\/128.00),2)),   convert(numeric(10,2),round(((sum(internal_object_reserved_page_count)*1.0)\/128.00),2)) from   tempdb.sys.dm_db_file_space_usage;<\/code><\/pre>\n<p>  \u0432\u044b\u0434\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 tempdb, \u0437\u0430\u043d\u044f\u0442\u043e\u0433\u043e version store (\u0434\u043b\u044f snapshot), user objects (#tab \u0438 ##tab) \u0438 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438\/\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u043b\u044f \u043d\u0438\u0445 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 (18+, \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043d\u0435\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b)<\/p>\n<pre><code class=\"sql\">dbcc addinstance ('SQLServer:User Settable', 'TempDB version store KB') dbcc addinstance ('SQLServer:User Settable', 'TempDB user store KB') dbcc addinstance ('SQLServer:User Settable', 'TempDB sort store KB') <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0442\u0440\u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0432 SQLServer -&gt; UserSettable -&gt; Query. \u041c\u0435\u0442\u0440\u0438\u043a\u0438 \u0446\u0435\u043b\u044b\u0435 \u2014 int (\u043d\u0435 bigint). \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f &#8216;\u043a\u0430\u043a \u0435\u0441\u0442\u044c&#8217;. \u0422\u043e \u0435\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u0430 \u0434\u0435\u043b\u044c\u0442\u0430 \u043e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0442\u043e \u044d\u0442\u043e \u0432\u0430\u0448\u0430 \u0437\u0430\u0431\u043e\u0442\u0430. \u041d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"sql\">declare @TEMPDBver int, @TEMPDBuser int, @TEMPDBsort int select  @TEMPDBver = convert(numeric(10,2),round(((sum(version_store_reserved_page_count) *1.0)\/128.00),2)), @TEMPDBuser = convert(numeric(10,2),round(((sum(user_object_reserved_page_count) *1.0)\/128.00),2)), @TEMPDBsort = convert(numeric(10,2),round(((sum(internal_object_reserved_page_count) *1.0)\/128.00),2)) from tempdb.sys.dm_db_file_space_usage;  if @TEMPDBver is not null       dbcc setinstance ('SQLServer:User Settable', 'Query',      'TempDB version store KB', @TEMPDBver) if @TEMPDBuser is not null      dbcc setinstance ('SQLServer:User Settable', 'Query',     'TempDB user store KB', @TEMPDBuser) if @TEMPDBsort is not null      dbcc setinstance ('SQLServer:User Settable', 'Query',      'TempDB sort store KB', @TEMPDBsort)<\/code><\/pre>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u0441\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0439\u0442\u0435 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u0438 \u0432\u0441\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<h3>\u0421\u0447\u0435\u0442\u0447\u0438\u043a\u0438 \u0441 \u0434\u0435\u043b\u044c\u0442\u043e\u0439<\/h3>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043c\u0430\u0441\u0442\u0435\u0440\u0438\u043c \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0441 \u0434\u0435\u043b\u044c\u0442\u043e\u0439. \u042d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0440\u0435\u043c\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0432 ms.<\/p>\n<pre><code class=\"sql\">dbcc addinstance ('SQLServer:User Settable', 'LOCK ms per s') <\/code><\/pre>\n<p>  \u0422\u0443\u0442 \u0432\u044b \u043c\u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u043e\u0437\u0440\u0430\u0437\u0438\u0442\u044c, \u0447\u0442\u043e \u0442\u0430\u043a\u0430\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c:<\/p>\n<pre><code class=\"sql\">select * from sys.dm_os_performance_counters    where counter_name like 'Lock Wait Time (ms)%'      and instance_name='_Total'     and object_name='SQLServer:Locks' <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u0430 \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0448\u044c eventually consistent. \u041a\u0430\u043a \u0432\u044b \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0442\u043e\u043d\u044b \u043d\u0435\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u044b, \u0442\u043e \u043b\u044e\u0431\u0430\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u043e \u0432\u0441\u0435\u043b\u0435\u043d\u043d\u043e\u0439 is eventually consistent. \u0422\u043e \u0435\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u0442\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0443 \u0438 \u0431\u0443\u0434\u0435\u0442\u0435 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u0442\u043e \u0440\u0430\u0441\u0442\u0438 \u043e\u043d\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442! \u0418 \u043b\u0438\u0448\u044c \u043f\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0438 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u043a\u043e \u043f\u0440\u044b\u0433\u043d\u0435\u0442 \u043d\u0430 \u043f\u043e\u043b\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f. \u041d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0433\u043e &#8216;\u043f\u043b\u0430\u0442\u043e&#8217; \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0440\u0435\u0437\u043a\u0438\u0439 \u043f\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0449\u0435 \u0438 \u0438\u0441\u043f\u043e\u0440\u0442\u0438\u0442 \u0432\u0430\u043c \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u043f\u043e \u043e\u0441\u0438 Y.<\/p>\n<p>  \u0422\u0430 \u0436\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0435\u0441\u0442\u044c \u0443 \u043a\u0432\u0435\u0440\u0438:<\/p>\n<pre><code class=\"sql\">select sum(wait_time_ms)    from sys.dm_os_wait_stats    where wait_type like 'LCK_%'<\/code><\/pre>\n<p>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043a \u0432\u0440\u0435\u043c\u0435\u043d\u0438 &#8216;\u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u044b\u0445&#8217; \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0442\u0435\u043a\u0443\u0449\u0438\u0445:<\/p>\n<pre><code class=\"sql\">declare @NEWlock bigint select @NEWlock=sum(wait_time_ms)    from sys.dm_os_wait_stats    where wait_type like 'LCK_%' -- finished waits select @NEWlock=@NEWlock+isnull(sum(waittime),0)    from master.dbo.sysprocesses    where blocked&gt;0 and lastwaittype like 'LCK_%' -- waits in progress <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u044d\u0442\u0430 \u043a\u0432\u0435\u0440\u044c \u0443\u0436\u0435 \u0434\u0430\u0435\u0442 \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u043f\u043b\u0430\u0442\u043e.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u0435\u043b\u044c\u0442\u0443 \u043e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0422\u0443\u0442 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430:<\/p>\n<ul>\n<li>\u041e\u0444\u043e\u0440\u043c\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043a\u0430\u043a job, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u043e (\u0441\u043a\u0430\u0436\u0435\u043c, \u0440\u0430\u0437 \u0432 \u043c\u0438\u043d\u0443\u0442\u0443). \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0443 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0437\u043d\u0430\u0447\u0438\u0435\u043d\u0438\u0439. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0447\u0430\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c job \u043f\u043b\u043e\u0445\u043e (\u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b + \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0446\u0438\u044f \u0437\u0430 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f Jobs ), \u0434\u0430 \u0438 \u0431\u0435\u0437 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c:<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435 c waitfor. \u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u043c\u043d\u0438\u0442 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0444\u043e\u0440\u043c\u0438\u043c \u043a\u0430\u043a job \u0441 \u0434\u0432\u0443\u043c\u044f schedule: \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u0438 \u0440\u0430\u0437 \u0432 \u0447\u0430\u0441 (\u043d\u0430 \u0442\u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 job \u0443\u043f\u0430\u043b\u0430 \u2014 \u043e\u043d\u0430 \u0442\u043e\u0433\u0434\u0430 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0441\u044f)<\/li>\n<\/ul>\n<p>  \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0446\u0438\u043a\u043b \u0440\u0430\u0437 \u0432 \u043f\u044f\u0442\u044c \u0441\u0435\u043a\u0443\u043d\u0434 \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0447\u0430\u0449\u0435. \u0418\u0442\u0430\u043a, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c:<\/p>\n<pre><code class=\"sql\">declare @OLDlock bigint, @NEWlock bigint declare @lock int, @seconds int = 5 -- must match WAITFOR loop:   set @OLDlock=@NEWlock -- shift new to old   select @NEWlock=sum(wait_time_ms)      from sys.dm_os_wait_stats  \twhere wait_type like 'LCK_%' -- finished waits   select @NEWlock=@NEWlock+isnull(sum(waittime),0)      from master.dbo.sysprocesses  \twhere blocked&gt;0 and lastwaittype like 'LCK_%' -- waits in progress   set @lock=(@NEWlock-@OLDlock)\/@seconds -- this is delta   if @lock is not null         dbcc setinstance ('SQLServer:User Settable', 'Query',  \t  'LOCK ms per s', @lock)   waitfor delay '00:00:05'  goto loop<\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0446\u0438\u043a\u043b\u0430 DBCC \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043e (\u0447\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e), \u0442\u0430\u043a \u043a\u0430\u043a @OLDlock (\u0438 <a href=\"https:\/\/habr.com\/ru\/users\/lock\/\" class=\"user_link\">lock<\/a>) \u0431\u0443\u0434\u0443\u0442 null.<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/497238\/\"> https:\/\/habr.com\/ru\/post\/497238\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/497238\/\">\u041d\u0430 \u0444\u043e\u0442\u043e \u0441\u0446\u0435\u043d\u0430 \u0438\u0437 \u0441\u0442\u0430\u0440\u043e\u0439 \u0434\u043e\u0431\u0440\u043e\u0439 \u043a\u043e\u043c\u0435\u0434\u0438\u0438 \u00ab\u0410\u044d\u0440\u043e\u043f\u043b\u0430\u043d\u00bb \u2014 \u0431\u0443\u043c\u0435\u0440\u044b \u043f\u043e\u043c\u043d\u044f\u0442 \u0435\u0435. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ln\/if\/dn\/lnifdnnc4rrtbmkaivipqr0gbks.jpeg\"><\/p>\n<p>  \u041e\u043d\u0430 \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e. \u041d\u043e \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-301886","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/301886","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=301886"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/301886\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=301886"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=301886"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=301886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}