Monday, September 22, 2008

Avoiding the Autoclose and Autoshrink Options


Q
In the Microsoft SQL Server 2000 Resource Kit, I read about a procedure that checks all databases for options that you should avoid using. I understand why I should avoid using options such as offline, DBO-use only, statistics off, truncate log on checkpoint, and so on. However, the inclusion of two of the options—autoclose and autoshrink—puzzles me.

Autoclose. Closing a file when it is not in use sounds like a prudent thing to do. Yet I see files opening and closing all the time in the error log in SQL Server, even though I know that I never use the database except for viewing in Enterprise Manager. Does viewing a list of databases in Enterprise Manager make the files open? It makes sense to me to use autoclose on databases that I use only occasionally as import staging areas, and which I access for only a fraction of the time my online transaction processing (OLTP) database is in use. SQL Server Books Online says that the autoclose option is automatically set to YES for the SQL Server Personal Edition and to NO for all other editions. Has this option been included only for the Personal Edition?

Autoshrink. The autoshrink option also sounds helpful. However, would using autoshrink on my import staging areas, where I bring in quantities of data for short periods of time, keep these areas small for backups?

A
Autoclose is available in all editions of SQL Server 2000. The amount of memory you save by using this option is relatively small but might be important on memory-constrained systems running the Personal Edition. However, enabling autoclose for the other editions isn't a good idea, because every time you try to access the database, the query will be slowed by the amount of load time it takes to mount the database. As for the question about your files opening and closing, yes, when you enumerate a database in Enterprise Manager, you access the database, which opens the files.

Leaving autoshrink on for production systems also isn't a good practice (unless you really need to), because autoshrink might start when your system is otherwise busy with production work, and slow down the system. However, enabling this option is a good idea for desktop or remote systems that don't get a lot of DBA attention and whose databases could grow out of control before you detect the problem.




Related Articles by Categories


0 comments:

Related Posts Plugin for WordPress, Blogger...
Grab this Widget ~ Blogger Accessories