|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Wednesday, March 27, 2013 8:55 AM
Points: 289,
Visits: 683
|
|
1 of the query's of a colleague of mine has been slowing down recently. He looked to the execution plans and the index fragmentation and found a fragmented index, which he then rebuild. No resolve, fragmentation was gone but the performance remained slow.
He then did an update statistics which resolved it. Now I'm confused,and the the things I found searching about it are contradicting.
If you rebuild an index the statistics get updated,is this the case or not. I've requested more info on the table and query.
But anyone who can tell me why you would need an update statistics after an index rebuild please do. Is there a way to check all statistics of a table
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 1:24 PM
Points: 6,826,
Visits: 11,950
|
|
USE AdventureWorks2012;
DECLARE @schema_name SYSNAME, @table_name SYSNAME;
SELECT @schema_name = N'HumanResources', @table_name = N'Department';
SELECT st.name AS StatsName, STATS_DATE(st.object_id, st.stats_id) AS [LastUpdated] FROM sys.objects AS tbl INNER JOIN sys.stats st ON st.object_id = tbl.object_id WHERE tbl.name = @table_name AND SCHEMA_NAME(tbl.schema_id) = @schema_name;
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: 2 days ago @ 11:31 PM
Points: 754,
Visits: 1,100
|
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 1:24 PM
Points: 6,826,
Visits: 11,950
|
|
foxxo (1/16/2013)
It wasn't the statistics that fixed the issue, it was the query being recompiled (ie. new plan). From BOL: http://msdn.microsoft.com/en-us/library/ms187348.aspxUpdating statistics ensures that queries compile with up-to-date statistics. However, updating statistics causes queries to recompile. We recommend not updating statistics too frequently because there is a performance tradeoff between improving query plans and the time it takes to recompile queries. rebuilding an index automatically rebuilds the statistics on that index
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 7:38 AM
Points: 38,079,
Visits: 30,375
|
|
Could well be that the stats that the query depends on are column stats, not index stats. REbuilding an index only updates the stats associated with that index (and invalidates any plans that use it)
Gail Shaw Microsoft Certified Master: SQL Server 2008, MVP SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 1:24 PM
Points: 6,826,
Visits: 11,950
|
|
Column stats is the likely reason given the info.
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Wednesday, March 27, 2013 8:55 AM
Points: 289,
Visits: 683
|
|
GilaMonster (1/16/2013) Could well be that the stats that the query depends on are column stats, not index stats. REbuilding an index only updates the stats associated with that index (and invalidates any plans that use it)
opc.three (1/16/2013) Column stats is the likely reason given the info.
From the data I have and I've requested more an out of date statistic that is not part of the index he rebuild is the most likely cause of the problems. (I've came to the conclusion of this yesterday)
|
|
|
|