SQL SERVER - Database Files Initial Size Changing Automatically - SQL Authority with Pinal Dave
One of my clients reported an interesting issue and I was needed to wear detective cap to solve it. The mystery, for which they hired me was as below for Database Files Initial Size Changing Automatically.
Pinal,
We see an interesting issue, and we believe there is something not right with our environment. As per best practices from one of your blog, we have configured the initial file size of the database files to big enough for next 1 year data growth.
We are noticing that the file size is not getting set and it changes to smaller size every night. Would you be able to suggest us something?
MY INVESTIGATION
I asked them if there is any maintenance plan which runs every night and does the shrink of the database, like below?
And they said that they have no maintenance plan doing such activity.
Here are the various data points I looked at.
SELECT * FROM database_files
SELECT * FROM databases
sp_helpdb SAPDB
When I looked at sys.databases, I could see is_auto_shrink_on was set to 1.
You can run below query in you production database and make sure auto shrink is set to 0.
SELECT is_auto_shrink_on, * FROM sys.databases
ROOT CAUSE
As you can see above, we concluded that the behavior which they saw was because Auto Shrink property was set to ON for many databases. Since this was one of an active database, auto shrink was kicked as compared to other databases. This article discusses the use of both Auto options[1].
Reference: Pinal Dave (https://blog.sqlauthority.com[2])
References
- ^ Auto options (support.microsoft.com)
- ^ https://blog.sqlauthority.com (blog.sqlauthority.com)
Comments