Answered by:
ALTER INDEX / UPDATE STATISTICS

Question
-
Hi,
I have a question.
I'm doing an ALTER INDEX REBUILD statement using the clause STATISTICS_NORECOMPUTE to OFF.
If I rebuild the indexes I have to update the statistics using UPDATE STATISTICS command for that particular table or the ALTER INDEX REBUILD statement take care updating the statistics for me?Tuesday, March 3, 2009 2:16 PM
Answers
-
Yes, that is correct.
Tibor Karaszi- Marked as answer by amendez Tuesday, March 3, 2009 8:40 PM
Tuesday, March 3, 2009 8:38 PM
All replies
-
Hi,
As you are setting the STATISTICS_NORECOMPUTE to NO, You will manually need to update statistics on columns covered by your indexes.
Make sense?
Cheers, John
John Sansom | www.johnsansom.com | Please mark answers that solve your problem- Proposed as answer by John Sansom Tuesday, March 3, 2009 3:44 PM
Tuesday, March 3, 2009 3:05 PM -
ALTER INDEX ... REBUILD will give you fresh statistics as part of the index rebuild. But what you did was to turn off auto-update of statistics for that particular index.
Tibor KarasziTuesday, March 3, 2009 4:51 PM -
Hi,
I read that the clause STATISTICS_NORECOMPUTE in the ALTER INDEX by default is set to OFF.
I was just trying to find out if by leaving it OFF the statement calculates the statistics by it self or if it doesnt if I have to execute an UPDATE STATISTICS statement to get the statistics recalculated after the ALTER INDEX have been executed.Tuesday, March 3, 2009 6:11 PM -
If you leave this at the default, then the statistics will be auto-updated according tot he database setting for auto-update of statistics. But, again, the setting do no affect whether the index statistics is updated by the index rebuild in question - that is a natural and integral part of rebuilding an index.
Tibor KarasziTuesday, March 3, 2009 6:13 PM -
Hi,
TiborK I'm confuse now.
If I leave the default value in the alter index and the auto-update statistics setting in the database is not set, the statistics for the index will not be calculated with the alter index statement.
Is that what you mean?Tuesday, March 3, 2009 7:13 PM -
No, that is not what I'm saying. ALTER INDEX REBUILD will refresh the statistics. As I said, this is an integral part of index rebuild.
Tibor KarasziTuesday, March 3, 2009 8:00 PM -
Hi,
Thaks a lot.Tuesday, March 3, 2009 8:20 PM -
Ok, so I'm just goin to do the ALTER INDEX and omit UPDATE STATISTICS statement because the alter does update the statistics.Tuesday, March 3, 2009 8:37 PM
-
Yes, that is correct.
Tibor Karaszi- Marked as answer by amendez Tuesday, March 3, 2009 8:40 PM
Tuesday, March 3, 2009 8:38 PM