A question of mine which dealt with a slowly executing query introduced me to the sp_updatestats()
function. I want to take pro-active steps to call it on a regular basis rather that wait for my queries to randomly start timing out during business hours. I was considering running it at midnight each night. My questions are:
Is there a useful way to determine when this procedure should be called instead of blindly running it each night? The documentation says that SQL Server updates these stats on its own. But with what frequency? How do I know when I need to step in and execute it manually?
Does the database lock up while this procedure is being run? It seems to take about four or five minutes to do its thing. Will the database be accessible during this period or will attempted queries be blocked? My tests indicate that I can still run queries but I’m not sure if this is just because I got lucky, querying against a table for which stats weren't being calculated at that precise moment.