{"id":302,"date":"2006-11-25T16:16:47","date_gmt":"2006-11-25T14:16:47","guid":{"rendered":"http:\/\/www.glorf.it\/blog\/2006\/11\/25\/sql-talk\/sql2005-datenbank-option-auto_update_statistics_async"},"modified":"2006-11-29T14:09:27","modified_gmt":"2006-11-29T12:09:27","slug":"sql2005-datenbank-option-auto_update_statistics_async","status":"publish","type":"post","link":"http:\/\/www.glorf.it\/blog\/2006\/11\/25\/sql-talk\/sql2005-datenbank-option-auto_update_statistics_async","title":{"rendered":"SQL2005: Datenbank-Option AUTO_UPDATE_ STATISTICS_ASYNC"},"content":{"rendered":"<p>Heute wurde ich durch einen Blogeintrag im <a href=\"http:\/\/sqlservercode.blogspot.com\/2006\/11\/auto-update-statistics-asynchronously.html\" target=\"_blank\">Sqlservercode-Weblog<\/a> auf die Datenbank-Option AUTO_UPDATE_STATISTICS_ASYNC aufmerksam. Dort wird aus den <a href=\"http:\/\/msdn2.microsoft.com\/en-US\/library\/ms190397.aspx\">Books Online<\/a> zitiert:<\/p>\n<blockquote><p>In SQL Server 2005, the database option AUTO_UPDATE_STATISTICS_ASYNC provides asynchronous statistics updating. When this option is set to ON, queries do not wait for the statistics to be updated before compiling. Instead, the out-of-date statistics are put on a queue for updating by a worker thread in a background process. The query and any other concurrent queries compile immediately by using the existing out-of-date statistics. Because there is no delay for updated statistics, query response times are predictable; however, the out-of-date statistics may cause the query optimizer to choose a less-efficient query plan. <\/p><\/blockquote>\n<p>Das ist interessant f&#252;r Datenbanken deren Inhalte sich h&#228;ufig &#228;ndert, z.B. regelm&#228;&#223;ig viele Datens&#228;tze eingegeben oder gel&#246;scht werden. Ich kann mich durchaus an mehrere F&#228;lle in der Vergangenheit erinnern in denen unregelm&#228;&#223;ig die Ausf&#252;hrung von Statements viel l&#228;nger dauerte als es erkl&#228;rbar war. Im Nachhinein deutet vieles daraufhin, dass da die Statistiken nicht mehr aktuell waren und vor der Zusammenstellung des Zugriffsplans aktualisiert werden mussten. Das wird mir aber erst jetzt klar.<\/p>\n<p>Statistiken werden f&#252;r jeden Index angelegt, man kann sie manuell anlegen (auch f&#252;r indexierte Views) und manchmal werden sie automatisch angelegt, wenn zu wenige Indexes auf der Tabelle liegen. Das Verhalten kann also jeden treffen. Die Option einzuschalten ist aber nur dann sinnvoll, wenn auch ein Zugriffsplan basierend auf veralteten Statistiken noch eine akzeptable Performance bietet. Ich w&#252;rde vermuten, dass dies bei sinnvoll vergebenen &quot;clustered indexes&quot; meist der Fall ist und die &quot;dicksten&quot; Abfragen den Clustred-Index verwenden. Da muss man aber jeweils genauer hinsehen.<\/p>\n<p>Generell begeistert mich der Gedanke, dass der SQL-Server-2005 diese zeitaufw&#228;ndige Aktion dann macht, wenn er gerade wenig zu tun hat. Aber logischerweise bringt die Option nur dann einen Vorteil, wenn die (mehrfache) Ausf&#252;hrung eines Statements mit einem &quot;alten&quot; Zugriffsplan immer noch schneller ist als die Aktualisierung der Statistik(en) und die anschlie&#223;ende (mehrfache) Ausf&#252;hrung des Statements.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Heute wurde ich durch einen Blogeintrag im Sqlservercode-Weblog auf die Datenbank-Option AUTO_UPDATE_STATISTICS_ASYNC aufmerksam. Dort wird aus den Books Online zitiert: In SQL Server 2005, the database option AUTO_UPDATE_STATISTICS_ASYNC provides asynchronous statistics updating. When this option is set to ON, queries do not wait for the statistics to be updated before compiling. Instead, the out-of-date statistics [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"http:\/\/www.glorf.it\/blog\/wp-json\/wp\/v2\/posts\/302"}],"collection":[{"href":"http:\/\/www.glorf.it\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.glorf.it\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.glorf.it\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.glorf.it\/blog\/wp-json\/wp\/v2\/comments?post=302"}],"version-history":[{"count":0,"href":"http:\/\/www.glorf.it\/blog\/wp-json\/wp\/v2\/posts\/302\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.glorf.it\/blog\/wp-json\/wp\/v2\/media?parent=302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.glorf.it\/blog\/wp-json\/wp\/v2\/categories?post=302"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.glorf.it\/blog\/wp-json\/wp\/v2\/tags?post=302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}