Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How often are indexes updated? Expand / Collapse
Author
Message
Posted Tuesday, December 25, 2012 7:28 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Saturday, December 28, 2013 5:45 PM
Points: 94, Visits: 96
When an index is created with STATISTICS_NORECOMPUTE = OFF, how frequently is the index updated? Is it updated every time the table has new rows created on it?
Post #1400122
Posted Tuesday, December 25, 2012 11:29 PM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Tuesday, October 7, 2014 10:53 PM
Points: 3,421, Visits: 5,359
I'm pretty sure the index always gets updated when rows are INSERTed, UPDATEd or DELETEd regardless of the setting, because it must or the database would lose track of rows in the table. What is not updated is statistics on any queries that use the table.

If you add the INDEX with STATISTICS_NORECOMPUTE = ON, then existing statistics would be retained for all impacted queries, impairing the optimizer's ability to utilize the new INDEX to improve a queries performance. With it OFF, then the statistics would be updated when the INDEX is added.

Someone else may be better equipped to explain this than me though.

While they're at it, why did MS have to use STATISTICS_NORECOMPUTE instead of STATISTICS_RECOMPUTE? The double negative drives me batty!



My mantra: No loops! No CURSORs! No RBAR! Hoo-uh!

My thought question: Have you ever been told that your query runs too fast?

My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.


Need to UNPIVOT? Why not CROSS APPLY VALUES instead?
Since random numbers are too important to be left to chance, let's generate some!
Learn to understand recursive CTEs by example.
Splitting strings based on patterns can be fast!
Post #1400150
Posted Wednesday, December 26, 2012 1:10 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 5:50 AM
Points: 40,209, Visits: 36,618
Golfer22 (12/25/2012)
When an index is created with STATISTICS_NORECOMPUTE = OFF, how frequently is the index updated? Is it updated every time the table has new rows created on it?


Within the same operation as the base table. SQL's indexes are never out of sync with the table.

STATISTICS_NORECOMPUTE has nothing to do with the index itself. If it's set on it just means that that index's statistics object is not automatically updated.



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

Post #1400354
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse