{"id":8,"date":"2012-08-21T10:12:25","date_gmt":"2012-08-21T13:12:25","guid":{"rendered":"http:\/\/monitor.infracoop.com.ar\/blog2\/?p=8"},"modified":"2012-08-21T23:09:43","modified_gmt":"2012-08-22T02:09:43","slug":"problemas-de-performance","status":"publish","type":"post","link":"https:\/\/www.infracoop.com.ar\/?p=8","title":{"rendered":"Problemas de performance"},"content":{"rendered":"<p>El servidor tiene problemas de performance!<\/p>\n<p>Si un cliente te llama y te dice eso, directamente, sin un \u2018hola\u2019, es que est\u00e1 en problemas.<br \/>\nEntonces lo \u00fanico que se puede hacer es recabar un poco de informaci\u00f3n sobre el servidor, sobre los servicios, sobre si hubo alg\u00fan cambio, o si algo puede estar pasando que no estaba pasando \u2018antes\u2019.<\/p>\n<p>En este caso, un servidor SQLServer que, sin aviso, empez\u00f3 a desempe\u00f1arse de manera horrible, haciendo que el aplicativo que funcionaba usando esos datos sea inusable.<\/p>\n<p>Primero lo primero, chequear los \u00edndices y las fechas que se hayan refrescado:<\/p>\n<p>[sql]<br \/>\nSELECT USER_NAME( OBJECTPROPERTY( i.id, &#8216;OwnerID&#8217; ) )<br \/>\n AS OwnerName,<br \/>\n OBJECT_NAME( i.id ) AS TableName,<br \/>\n i.name AS IndexName,<br \/>\n CASE INDEXPROPERTY( i.id , i.name , &#8216;IsClustered&#8217;)<br \/>\n WHEN 1 THEN &#8216;YES&#8217;<br \/>\n ELSE &#8216;NO&#8217;<br \/>\n END AS IsClustered,<br \/>\n CASE INDEXPROPERTY( i.id , i.name , &#8216;IsUnique&#8217; \u00a0\u00a0\u00a0)<br \/>\n WHEN 1 THEN &#8216;YES&#8217;<br \/>\n ELSE &#8216;NO&#8217;<br \/>\n END AS IsUnique,<br \/>\n STATS_DATE( i.id , i.indid ) AS LastUpdatedDate<br \/>\n FROM sysindexes AS i<br \/>\n WHERE OBJECTPROPERTY( i.id, &#8216;IsMSShipped&#8217; ) = 0 And<br \/>\n 1 NOT IN ( INDEXPROPERTY( i.id , i.name , &#8216;IsStatistics&#8217; \u00a0\u00a0) ,<br \/>\n INDEXPROPERTY( i.id , i.name , &#8216;IsHypothetical&#8217; \u00a0\u00a0) ) And<br \/>\n i.indid BETWEEN 1 And 250<br \/>\n ORDER BY OwnerName, TableName, IndexName;<br \/>\n[\/sql]<\/p>\n<p>Pero esto no tiraba nada demasiado extra\u00f1o&#8230; asique se me ocurri\u00f3 chequear esto mismo, pero con \u2018And 1 = INDEXPROPERTY(i.id, i.name, &#8216;IsDisabled&#8217; )\u2019 antes del ORDER BY&#8230;<\/p>\n<p>Un mont\u00f3n de \u00edndices deshabilitados. Obviamente, \u2018nadie toc\u00f3\u2019. Por lo pronto, rehabilitar todos los \u00edndices para solucionar el problema:<\/p>\n<p>[sql]<br \/>\nDECLARE @Table VARCHAR(255)<br \/>\n DECLARE @cmd NVARCHAR(500)<br \/>\n DECLARE @fillfactor INT<br \/>\n SET @fillfactor = 90<\/p>\n<p>SET @cmd = &#8216;DECLARE Cursor4Tables CURSOR FOR SELECT &#8221;[&#8221; + table_catalog + &#8221;].[&#8221; + table_schema + &#8221;].[&#8221; +<br \/>\n table_name + &#8221;]&#8221; as tableName FROM INFORMATION_SCHEMA.TABLES<br \/>\n WHERE table_type = &#8221;BASE TABLE&#8221;&#8217;<br \/>\n&#8212; creando el cursor<br \/>\n EXEC (@cmd)<br \/>\n OPEN Cursor4Tables<br \/>\nFETCH NEXT FROM Cursor4Tables INTO @Table<br \/>\n WHILE @@FETCH_STATUS = 0<br \/>\n BEGIN<br \/>\n SET @cmd = &#8216;ALTER INDEX ALL ON &#8216; + @Table + &#8216; REBUILD WITH (FILLFACTOR = &#8216; + CONVERT(VARCHAR(3),@fillfactor) + &#8216;)&#8217;<br \/>\n EXEC (@cmd)<br \/>\n FETCH NEXT FROM Cursor4Tables INTO @Table<br \/>\n END<br \/>\nCLOSE Cursor4Tables<br \/>\n DEALLOCATE Cursor4Tables<br \/>\n[\/sql]<\/p>\n<p>Y listo!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>El servidor tiene problemas de performance! Si un cliente te llama y te dice eso, directamente, sin un \u2018hola\u2019, es que est\u00e1 en problemas. Entonces lo \u00fanico&hellip; <span class=\"read-more\"><a class=\"more-link\" href=\"https:\/\/www.infracoop.com.ar\/?p=8\" rel=\"bookmark\">Read more <span class=\"screen-reader-text\">&#8220;Problemas de performance&#8221;<\/span><\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[6,5],"class_list":["post-8","post","type-post","status-publish","format-standard","hentry","category-sqlserver","tag-cursores","tag-indices"],"_links":{"self":[{"href":"https:\/\/www.infracoop.com.ar\/index.php?rest_route=\/wp\/v2\/posts\/8","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.infracoop.com.ar\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.infracoop.com.ar\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.infracoop.com.ar\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.infracoop.com.ar\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8"}],"version-history":[{"count":13,"href":"https:\/\/www.infracoop.com.ar\/index.php?rest_route=\/wp\/v2\/posts\/8\/revisions"}],"predecessor-version":[{"id":157,"href":"https:\/\/www.infracoop.com.ar\/index.php?rest_route=\/wp\/v2\/posts\/8\/revisions\/157"}],"wp:attachment":[{"href":"https:\/\/www.infracoop.com.ar\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.infracoop.com.ar\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.infracoop.com.ar\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}