{"id":286844,"date":"2017-05-25T12:35:03","date_gmt":"2017-05-25T08:35:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=286844"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=286844","title":{"rendered":"\u0423\u0441\u043a\u043e\u0440\u044f\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0443 WSUS"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/c91\/596\/84a\/c9159684a2504a0881b9616a57cc914d.png\"\/><\/p>\n<p>  \u0421\u0432\u0435\u0436\u0435\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 WSUS \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u044d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0430\u0446\u0438\u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043d\u0435\u043f\u043e\u0432\u043e\u0440\u043e\u0442\u043b\u0438\u0432\u043e\u0435 \u0447\u0443\u0434\u043e\u0432\u0438\u0449\u0435. \u041a\u043b\u0438\u0435\u043d\u0442\u044b \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438 \u0434\u043e\u043b\u0433\u043e \u0438\u0449\u0443\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f, \u0436\u0443\u0440\u043d\u0430\u043b\u044b WindowsUpdate.log \u043f\u0435\u0441\u0442\u0440\u044f\u0442 \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438 HTTP, \u0430 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440 \u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0434\u0435\u043f\u0440\u0435\u0441\u0441\u0438\u044e.<br \/>  \u0412\u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0432\u0435\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440.<br \/>  <a name=\"habracut\"><\/a><\/p>\n<p>  <a href=\"https:\/\/habrahabr.ru\/topic\/329440\/#1\">1. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 IIS<\/a><br \/>  <a href=\"https:\/\/habrahabr.ru\/topic\/329440\/#2\">2. \u041e\u0447\u0438\u0441\u0442\u043a\u0430 \u0431\u0430\u0437\u044b<\/a><br \/>  <a href=\"https:\/\/habrahabr.ru\/topic\/329440\/#3\">3. \u041f\u0435\u0440\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044f<\/a><br \/>  <a href=\"https:\/\/habrahabr.ru\/topic\/329440\/#4\">4. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 TempDB<\/a><\/p>\n<h4><a name=\"1\"><\/a>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Internet Information Server<\/h4>\n<p>  \u0412 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u00ab\u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e\u00bb \u043f\u0443\u043b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u00abWsusPool\u00bb \u043d\u0435\u0437\u0430\u0441\u043b\u0443\u0436\u0435\u043d\u043d\u043e \u043e\u0431\u0434\u0435\u043b\u0451\u043d \u043f\u0430\u043c\u044f\u0442\u044c\u044e. \u042d\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 HTTP-\u043e\u0448\u0438\u0431\u043e\u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 \u0436\u0443\u0440\u043d\u0430\u043b\u0430\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432.<br \/>  \u0427\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 \u043f\u0430\u043c\u044f\u0442\u044c, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043e\u0441\u043d\u0430\u0441\u0442\u043a\u0443 IIS \u0438 \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 Advanced settings:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/3dd\/4af\/7be\/3dd4af7beda540acbfd6845020a5ccfa.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/97f\/d00\/e33\/97fd00e330bf4b43890c07c6a37ed63d.png\"\/><br \/>  \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043b\u0438\u043c\u0438\u0442\u0430 0.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/bdf\/a30\/c6d\/bdfa30c6d0a24ffea864e9ee584a794d.png\"\/><\/p>\n<h4><a name=\"2\"><\/a>\u041e\u0447\u0438\u0441\u0442\u043a\u0430 \u0431\u0430\u0437\u044b<\/h4>\n<p>  \u0412 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 WSUS \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u00abServer Cleanup Wizard\u00bb. \u0413\u043b\u0430\u0432\u043d\u044b\u0439 \u0441\u0435\u043a\u0440\u0435\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430\u0434\u043e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e, \u043d\u0435 \u0440\u0435\u0436\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0430 \u0432 \u043c\u0435\u0441\u044f\u0446.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/0fd\/712\/258\/0fd7122588c84002ba6b254bc455124e.PNG\"\/><br \/>  \u041e\u0434\u043e\u0431\u0440\u0438\u043b\u0438 \u0441\u0432\u0435\u0436\u0443\u044e \u043f\u0430\u0447\u043a\u0443 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u2014 \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u0435 \u0441\u0435\u0440\u0432\u0435\u0440. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c, \u043c\u0430\u0441\u0442\u0435\u0440 \u043f\u0440\u0435\u043a\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043e\u043d \u0432\u0438\u0441\u0438\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u043e\u0432, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439.<br \/>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0443\u043d\u043a\u0442 \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/4a3\/1ae\/8c6\/4a31ae8c61894911a5fe58458940bdd6.png\"\/><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442, \u043d\u0430\u0434\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u0447\u0438\u0441\u0442\u043a\u0443 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 \u0431\u0430\u0437\u0435.<br \/>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0443 SQL Server \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c Management Studio.<br \/>  Management Studio \u0441\u0442\u0430\u043b\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u043c. \u0415\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u043f\u043e \u044d\u0442\u043e\u0439 <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/ssms\/download-sql-server-management-studio-ssms\">\u0441\u0441\u044b\u043b\u043a\u0435<\/a>.<br \/>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 Windows Internal Database, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c Management Studio \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 WSUS. \u0414\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u0430:<br \/>  <code>\\\\.\\pipe\\MICROSOFT##WID\\tsql\\query<\/code><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/32a\/f18\/d79\/32af18d79ccb48138d6e7d1882d9390c.png\"\/><br \/>  \u0414\u043b\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0431\u0430\u0437\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 4 \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<pre><code class=\"sql\">EXEC SUSDB.dbo.spDeclineExpiredUpdates;1<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"sql\">EXEC SUSDB.dbo.spDeclineSupersededUpdates;1<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b <b>spCompressUpdate<\/b> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u00ab\u043e\u0431\u0451\u0440\u0442\u043a\u0430\u00bb:  <\/p>\n<pre><code class=\"sql\">USE SUSDB DECLARE @var1 INT, @curitem INT, @totaltodelete INT DECLARE @msg nvarchar(200) CREATE TABLE #results (Col1 INT) INSERT INTO #results(Col1) EXEC spGetUpdatesToCompress SET @totaltodelete = (SELECT COUNT(*) FROM #results) SELECT @curitem=1 DECLARE WC Cursor FOR SELECT Col1 FROM #results OPEN WC FETCH NEXT FROM WC INTO @var1 WHILE (@@FETCH_STATUS &gt; -1) BEGIN SET @msg = cast(@curitem as varchar(5)) + '\/' + cast(@totaltodelete as varchar(5)) + ': Compressing ' + CONVERT(varchar(10), @var1) + ' ' + cast(getdate() as varchar(30)) RAISERROR(@msg,0,1) WITH NOWAIT EXEC spCompressUpdate @localUpdateID=@var1 SET @curitem = @curitem +1 FETCH NEXT FROM WC INTO @var1 END CLOSE WC DEALLOCATE WC DROP TABLE #results <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0430\u044f \u0436\u0435 \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u0434\u043b\u044f <b>spDeleteUpdate<\/b>:  <\/p>\n<pre><code class=\"sql\">USE SUSDB DECLARE @var1 INT, @curitem INT, @totaltodelete INT DECLARE @msg nvarchar(200) CREATE TABLE #results (Col1 INT) INSERT INTO #results(Col1) EXEC spGetObsoleteUpdatesToCleanup SET @totaltodelete = (SELECT COUNT(*) FROM #results) SELECT @curitem=1 DECLARE WC Cursor FOR SELECT Col1 FROM #results OPEN WC FETCH NEXT FROM WC INTO @var1 WHILE (@@FETCH_STATUS &gt; -1) BEGIN SET @msg = cast(@curitem as varchar(5)) + '\/' + cast(@totaltodelete as varchar(5)) + ': Deleting ' + CONVERT(varchar(10), @var1) + ' ' + cast(getdate() as varchar(30)) RAISERROR(@msg,0,1) WITH NOWAIT EXEC spDeleteUpdate @localUpdateID=@var1 SET @curitem = @curitem +1 FETCH NEXT FROM WC INTO @var1 END CLOSE WC DEALLOCATE WC DROP TABLE #results <\/code><\/pre>\n<p>  \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u00ab\u043e\u0431\u0451\u0440\u0442\u043e\u043a\u00bb \u043a\u043b\u0438\u0435\u043d\u0442\u044b \u043f\u0440\u0435\u043a\u0440\u0430\u0449\u0430\u044e\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432 \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0440\u0435\u0440\u0432\u0430\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u0438 \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441\u0430. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443:  <\/p>\n<pre><code class=\"sql\">DROP TABLE #results<\/code><\/pre>\n<p>  \u0412 \u043c\u0430\u0441\u0442\u0435\u0440\u0435 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 5 \u043a\u043e\u043c\u0430\u043d\u0434, \u043c\u044b \u0432\u043f\u043e\u043b\u043d\u0438\u043b\u0438 4 \u0438\u0437 \u043d\u0438\u0445. \u041a\u043e\u043c\u0430\u043d\u0434\u0443 <b>\u00abDelete computers not contacting server\u00bb<\/b> \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0438\u0437 \u043c\u0430\u0441\u0442\u0435\u0440\u0430.<\/p>\n<h4><a name=\"3\"><\/a>\u041f\u0435\u0440\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044f \u0431\u0430\u0437\u044b<\/h4>\n<p>  \u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 \u0431\u0430\u0437\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 <a href=\"https:\/\/gallery.technet.microsoft.com\/scriptcenter\/6f8cde49-5c52-4abd-9820-f1d270ddea61\">\u0441\u043a\u0440\u0438\u043f\u0442<\/a>:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u0438\u043f\u0442 \u043f\u0435\u0440\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">\/******************************************************************************  This sample T-SQL script performs basic maintenance tasks on SUSDB  1. Identifies indexes that are fragmented and defragments them. For certain     tables, a fill-factor is set in order to improve insert performance.     Based on MSDN sample at http:\/\/msdn2.microsoft.com\/en-us\/library\/ms188917.aspx     and tailored for SUSDB requirements  2. Updates potentially out-of-date table statistics.  ******************************************************************************\/    USE SUSDB;  GO  SET NOCOUNT ON;    -- Rebuild or reorganize indexes based on their fragmentation levels  DECLARE @work_to_do TABLE (      objectid int      , indexid int      , pagedensity float      , fragmentation float      , numrows int  )    DECLARE @objectid int;  DECLARE @indexid int;  DECLARE @schemaname nvarchar(130);   DECLARE @objectname nvarchar(130);   DECLARE @indexname nvarchar(130);   DECLARE @numrows int  DECLARE @density float;  DECLARE @fragmentation float;  DECLARE @command nvarchar(4000);   DECLARE @fillfactorset bit  DECLARE @numpages int    -- Select indexes that need to be defragmented based on the following  -- * Page density is low  -- * External fragmentation is high in relation to index size  PRINT 'Estimating fragmentation: Begin. ' + convert(nvarchar, getdate(), 121)   INSERT @work_to_do  SELECT      f.object_id      , index_id      , avg_page_space_used_in_percent      , avg_fragmentation_in_percent      , record_count  FROM       sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL , NULL, 'SAMPLED') AS f  WHERE      (f.avg_page_space_used_in_percent &lt; 85.0 and f.avg_page_space_used_in_percent\/100.0 * page_count &lt; page_count - 1)      or (f.page_count &gt; 50 and f.avg_fragmentation_in_percent &gt; 15.0)      or (f.page_count &gt; 10 and f.avg_fragmentation_in_percent &gt; 80.0)    PRINT 'Number of indexes to rebuild: ' + cast(@@ROWCOUNT as nvarchar(20))    PRINT 'Estimating fragmentation: End. ' + convert(nvarchar, getdate(), 121)    SELECT @numpages = sum(ps.used_page_count)  FROM      @work_to_do AS fi      INNER JOIN sys.indexes AS i ON fi.objectid = i.object_id and fi.indexid = i.index_id      INNER JOIN sys.dm_db_partition_stats AS ps on i.object_id = ps.object_id and i.index_id = ps.index_id    -- Declare the cursor for the list of indexes to be processed.  DECLARE curIndexes CURSOR FOR SELECT * FROM @work_to_do    -- Open the cursor.  OPEN curIndexes    -- Loop through the indexes  WHILE (1=1)  BEGIN      FETCH NEXT FROM curIndexes      INTO @objectid, @indexid, @density, @fragmentation, @numrows;      IF @@FETCH_STATUS &lt; 0 BREAK;        SELECT           @objectname = QUOTENAME(o.name)          , @schemaname = QUOTENAME(s.name)      FROM           sys.objects AS o          INNER JOIN sys.schemas as s ON s.schema_id = o.schema_id      WHERE           o.object_id = @objectid;        SELECT           @indexname = QUOTENAME(name)          , @fillfactorset = CASE fill_factor WHEN 0 THEN 0 ELSE 1 END      FROM           sys.indexes      WHERE          object_id = @objectid AND index_id = @indexid;        IF ((@density BETWEEN 75.0 AND 85.0) AND @fillfactorset = 1) OR (@fragmentation &lt; 30.0)          SET @command = N'ALTER INDEX ' + @indexname + N' ON ' + @schemaname + N'.' + @objectname + N' REORGANIZE';      ELSE IF @numrows &gt;= 5000 AND @fillfactorset = 0          SET @command = N'ALTER INDEX ' + @indexname + N' ON ' + @schemaname + N'.' + @objectname + N' REBUILD WITH (FILLFACTOR = 90)';      ELSE          SET @command = N'ALTER INDEX ' + @indexname + N' ON ' + @schemaname + N'.' + @objectname + N' REBUILD';      PRINT convert(nvarchar, getdate(), 121) + N' Executing: ' + @command;      EXEC (@command);      PRINT convert(nvarchar, getdate(), 121) + N' Done.';  END    -- Close and deallocate the cursor.  CLOSE curIndexes;  DEALLOCATE curIndexes;      IF EXISTS (SELECT * FROM @work_to_do)  BEGIN      PRINT 'Estimated number of pages in fragmented indexes: ' + cast(@numpages as nvarchar(20))      SELECT @numpages = @numpages - sum(ps.used_page_count)      FROM          @work_to_do AS fi          INNER JOIN sys.indexes AS i ON fi.objectid = i.object_id and fi.indexid = i.index_id          INNER JOIN sys.dm_db_partition_stats AS ps on i.object_id = ps.object_id and i.index_id = ps.index_id        PRINT 'Estimated number of pages freed: ' + cast(@numpages as nvarchar(20))  END  GO     --Update all statistics  PRINT 'Updating all statistics.' + convert(nvarchar, getdate(), 121)   EXEC sp_updatestats  PRINT 'Done updating statistics.' + convert(nvarchar, getdate(), 121)   GO  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<h4><a name=\"4\"><\/a>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 TempDB<\/h4>\n<p>  Microsoft <a href=\"https:\/\/support.microsoft.com\/ru-ru\/help\/2154845\/recommendations-to-reduce-allocation-contention-in-sql-server-tempdb-database\">\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442<\/a>:  <\/p>\n<blockquote><p>As a general rule, if the number of logical processors is less than or equal to 8, use the same number of data files as logical processors. If the number of logical processors is greater than 8, use 8 data files and then if contention continues, increase the number of data files by multiples of 4 (up to the number of logical processors) until the contention is reduced to acceptable levels or make changes to the workload\/code.<\/p><\/blockquote>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/2dd\/b3e\/b29\/2ddb3eb29a1c4c27838910d5a5195130.png\"\/><br \/>  \u042d\u0442\u0443 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u044e \u043d\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u042f \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0441\u044c \u043d\u0430 \u0447\u0435\u0442\u044b\u0440\u0435\u0445 \u0444\u0430\u0439\u043b\u0430\u0445. \u041d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u043e\u0432 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0438\u0441\u0447\u0435\u0437\u0430\u044e\u0442.<\/p>\n<p>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435. \u0417\u043d\u0430\u0435\u0442\u0435 \u0435\u0449\u0435 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0444\u0438\u0448\u043a\u0438 \u2014 \u0434\u0435\u043b\u0438\u0442\u0435\u0441\u044c!<br \/> \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:\/\/habrahabr.ru\/post\/329440\/\"> https:\/\/habrahabr.ru\/post\/329440\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/c91\/596\/84a\/c9159684a2504a0881b9616a57cc914d.png\"\/><\/p>\n<p>  \u0421\u0432\u0435\u0436\u0435\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 WSUS \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u044d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0430\u0446\u0438\u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043d\u0435\u043f\u043e\u0432\u043e\u0440\u043e\u0442\u043b\u0438\u0432\u043e\u0435 \u0447\u0443\u0434\u043e\u0432\u0438\u0449\u0435. \u041a\u043b\u0438\u0435\u043d\u0442\u044b \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438 \u0434\u043e\u043b\u0433\u043e \u0438\u0449\u0443\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f, \u0436\u0443\u0440\u043d\u0430\u043b\u044b WindowsUpdate.log \u043f\u0435\u0441\u0442\u0440\u044f\u0442 \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438 HTTP, \u0430 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440 \u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u0434\u0435\u043f\u0440\u0435\u0441\u0441\u0438\u044e.<br \/>  \u0412\u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0432\u0435\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440.  <\/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-286844","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/286844","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=286844"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/286844\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=286844"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=286844"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=286844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}