<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SQL Aloha &#187; Database Maintenance</title>
	<atom:link href="http://www.bradmcgehee.com/category/database-maintenance/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bradmcgehee.com</link>
	<description>Brad M. McGehee, Director of DBA Education, Red Gate Software</description>
	<lastBuildDate>Tue, 27 Jul 2010 00:52:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Instant File Initialization Speeds SQL Server</title>
		<link>http://www.bradmcgehee.com/2010/07/instant-file-initialization-speeds-sql-server/</link>
		<comments>http://www.bradmcgehee.com/2010/07/instant-file-initialization-speeds-sql-server/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 19:20:28 +0000</pubDate>
		<dc:creator>bradmcgehee</dc:creator>
				<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Database Maintenance]]></category>

		<guid isPermaLink="false">http://www.bradmcgehee.com/2010/07/instant-file-initialization-speeds-sql-server/</guid>
		<description><![CDATA[Sometimes, its just the smallest of details that can make all the difference. For example, on my test system (see the end of this posting for a description), I created a new 50GB database. The database creation process took about 5 minutes and 50 seconds to complete.
 
Next, I populated the database with over 61 [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes, its just the smallest of details that can make all the difference. For example, on my test system (see the end of this posting for a description), I created a new 50GB database. The database creation process took about 5 minutes and 50 seconds to complete.</p>
<p> <span id="more-1704"></span>
<p>Next, I populated the database with over 61 million rows of data, which virtually occupied all of the available space within the newly created database. After that, I backed up the database using SSMS, and then I deleted the original database.</p>
<p>At this point, I restored the database from the backup using SSMS. Below, you see the typical Restore Database screen.</p>
<p><a href="http://www.bradmcgehee.com/wp-content/uploads/2010/07/image1.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.bradmcgehee.com/wp-content/uploads/2010/07/image_thumb1.png" width="539" height="494" /></a>&#160; </p>
<p>At the bottom, right-hand side of the screen in the Progress box, notice the “Executing (0%)” indicator. Between the time I clicked the OK button to begin the restore, and when the “Executing (0%)” counter began to move, it took about 5 minutes and 50 seconds. At that point, the counter began to increment and the database was restored.</p>
<p>Now I make one very small change to my SQL Server instance (I’ll describe it in just a moment), and then I repeat the above steps (after deleting the database I just restored). First, I created a new 50GB database. This time, instead of taking 5 minutes and 50 seconds to create the database, it takes just under 2 seconds, a savings of about 5 minutes and 48 seconds. Next, I populated the database with the same amount of data as before, backed it up, and then deleted the original file. When I restored the database this time around, instead of having to wait 5 minutes and 50 seconds before the backup began to restore, I only had to wait just under 2 seconds. In both of these cases, I saved a significant amount of time.</p>
<p>So what was the very small change that I made, and why did it radically reduce the amount of time for database creation and database restoration to occur? I turned instant file initialization on. </p>
<p><strong>What is Instant File Initialization?</strong></p>
<p>In my first two examples, before instance file initialization was turned on, the reason it took so long for the database to be created, or the database to be restored (before a database can be restored, its space must first be pre-allocated, much like creating a new database), SQL Server had to go to every page in the 50 GB database and zero each one of them out. It can take a lot of time for SQL Server to go to every 8K page in a file (especially very large files) and physically zero out each page. When instant file initialization is turned on, SQL Server doesn’t have to zero out every 8K page that has been allocated. Instead, the space is just allocated to SQL Server by the operating system in one fell swoop, which is a very quick process, potentially saving you a great deal of time.</p>
<p><strong>How Do You Turn Instant File Initialization On?</strong></p>
<p>Unlike most configuration features in SQL Server, there is no on/off switch for instant file initialization. Instead, you have to assign a specific user right to the SQL Server Service (mssqlserver) account. Here’s what you need to do to turn on instant file initialization.</p>
<p>First of all, to use instant file initialization with SQL Server in a production environment, you must be using some combination of:</p>
<ul>
<li><font color="#000000" size="2" face="Arial">Windows Server 2003 or</font></li>
<li><font color="#000000" size="2" face="Arial">Windows Server 2008 or</font></li>
<li><font color="#000000" size="2" face="Arial">Windows Server 2008 R2</font> </li>
</ul>
<p>and using:</p>
<ul>
<li><font color="#000000" size="2" face="Arial">SQL Server 2005 (any edition) or</font></li>
<li><font color="#000000" size="2" face="Arial">SQL Server 2008 (any edition) or</font></li>
<li><font color="#000000" size="2" face="Arial">SQL Server 2008 R2 (any edition)</font> </li>
</ul>
<p>Second, you must assign the SQL Server Service (mssqlserver) a special user right called “Perform volume maintenance tasks”. To do this, start the Local Security Policy tool (you must be a local administrator to perform this task), then drill down to Security Settings | Local Policies | User Rights Assignment | Perform volume maintenance tasks, as you see in the screenshot below.</p>
<p><a href="http://www.bradmcgehee.com/wp-content/uploads/2010/07/image2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="" border="0" alt="" src="http://www.bradmcgehee.com/wp-content/uploads/2010/07/image_thumb2.png" width="644" height="471" /></a> </p>
<p>Once you have located “Perform volume maintenance tasks”, right-click on it and select “Properties”, and the “Perform volume maintenance tasks Properties” screen appears. Click on “Add User or Group” and then proceed through the remaining screens until you select the account that is being used as the service account for SQL Server. In the screen shot below, notice that I have added the BRADMCGEHEE\sqlserverservice account to this user rights assignment. This is the user account I use on my test server to run my SQL Server instance.</p>
<p><a href="http://www.bradmcgehee.com/wp-content/uploads/2010/07/image3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="" border="0" alt="" src="http://www.bradmcgehee.com/wp-content/uploads/2010/07/image_thumb3.png" width="644" height="471" /></a> </p>
<p>Once the SQL Server service account has been assigned this user right, you will have to restart the SQL Server service (of course, only when it is not being used), and from this point forward, instant file initialization is turned on for all MDF files in your SQL Server instance.</p>
<blockquote><p>Note: If your SQL Server service account is a member of the local administrators group, then the account already has the “Perform volume maintenance tasks” user right and you don’t need to assign it again.</p>
</blockquote>
<p><strong>Why Isn’t Instant File Initialization Turned On by Default?</strong></p>
<p>When a SQL Server instance is first installed, one of the things you must enter is a SQL Server service account. If you follow the best practice and select a domain user account to be used as the SQL Server service account, the setup process automatically assigns the domain user account with only just enough rights and permissions to run SQL Server. The “Perform volume maintenance tasks” user right is not automatically assigned during installation because it is not required to run SQL Server, and because allowing the service account to have this additional user right introduces a very small security risk.</p>
<p>Oh no, a security risk! Well, not really much of a security risk. Here’s the possible security risk scenario. The disk that is being used to create the new database on has been used for storing data that has been previously deleted. As you may know, when data is deleted from disk by the operating system, it really is not physically deleted; the space holding the data is just marked as being available. At some point, the older data will be overwritten with new data. This occurs all the time on millions of computers throughout the world every day. And as such, any data that has been marked for deletion, but not yet overwritten, is potentially available for access if you have the right tools and know what you are doing. In fact, undelete software uses this to recover data that has been accidently deleted.</p>
<p>When instant file initialization is not turned on, and when SQL Server allocates space for an MDF file, each of the pages allocated for the database is zeroed out, which removes the older data, in theory, preventing it from being accessed. I say “in theory” because there are computer forensics techniques that can even recover data that has been overwritten, but that discussion is really not applicable here.</p>
<p>So if instant file initialization is turned on, there is a very slight risk that someone could go to the pages allocated for the new database and read any older data that still may exist there. This is essentially a non-issue in virtually every organization, other than those that require very high security. But because of this potential security issue, instant file initialization is not turned on by default.</p>
<blockquote><p>If instant file initialization is turned on, and pages are not zeroed out when the database is initially created, SQL Server will automatically overwrite any data that might have been on those pages when SQL Server needs that space.</p>
</blockquote>
<p><strong>When Is Instant File Initialization Used?</strong></p>
<p>If instant file initialization is turned on, it is used in all of these cases:</p>
<ul>
<li><font color="#000000" size="2" face="Arial">When a database is first created</font></li>
<li><font color="#000000" size="2" face="Arial"><font color="#000000" size="2" face="Arial">When a an existing database’s size is manually increased</font> </font></li>
<li><font color="#000000" size="2" face="Arial">When tempdb is recreated each time SQL Server is restarted</font></li>
<li><font color="#000000" size="2" face="Arial">When autogrowth kicks in</font> </li>
<li><font color="#000000" size="2" face="Arial">When backups are restored (as the space has to be pre-allocated before a restore can occur)</font>&#160;</li>
</ul>
<p>Instant file initialization only affects MDF and NDF files, not LDF files. In other words, transaction log files can’t take advantage of instant file initialization. This is because log files are circular in nature and must be zeroed out, as random data in transaction log pages can be problematic. In my earlier test, when I created a new 50 GB database, the MDF file was 50 GB and the log file was only 1 MB. If I had created a large log file (which is not uncommon), it would have taken awhile for the log to be created, although the MDF file would have been instantly created. This is also true when you manually increase the size of a log file, or when log file autogrowth occurs. In other words, don’t expect to have all of your databases (MDF and LDF files) created in less than 2 seconds like in my test. While the MDF will be created virtually instantly, the log file may take awhile to be created.</p>
<blockquote><p>When I was working with SQL Server 2000 a few years back, which does not support instant file initialization, one of the things that annoyed me the most when restoring large databases was waiting for the database space to be allocated before the restore actually began. During emergency database restores, this wasted a lot of precious time, preventing me from getting the database back into production as fast as I would have preferred. If you aren’t using instant file initialization today, you are facing this same problem. That’s why I recommend all SQL Server 2005/2008 instances have instant file initialization turned on. The time saved when restoring databases is the best reason to use instant file initialization.</p>
</blockquote>
<p><strong>Check to See if Your SQL Server Instances Have Instant File Initialization Turned On</strong></p>
<p>Hopefully, by now, you see the benefits of using instant file initialization. Assuming that you don’t already know if instant file initialization is turned on or off on the SQL Servers your manage, I challenge you to check and see, and if you find it turned off, turn it on and reap its many benefits.</p>
<p>&#160;</p>
<blockquote><p><strong>Test Hardware</strong></p>
<ul>
<li>Dell T610 Tower, with a single, 6-core CPU (Intel Xeon X5670, 2.93 Ghz, 12M Cache, HT, 1333MHz FSB); 32GB 1333MHz RAM; a PERC H700 RAID controller; two 146GB 15K SAS Drives; one dual-port HBA (to connect to the DAS); and dual network connections. Hyper-threading turned off. </li>
<li>One PowerVault MD3000 DAS with two, dual-port controllers, and 15 146GB 15K SAS drives. MDF files located on RAID 10 array with 10 spindles, LDF files on RAID 10 array with 4 spindles, backup drive on a single spindle. </li>
</ul>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.bradmcgehee.com/2010/07/instant-file-initialization-speeds-sql-server/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>SQL Server Monitoring Checklist</title>
		<link>http://www.bradmcgehee.com/2010/05/sql-server-monitoring-checklist/</link>
		<comments>http://www.bradmcgehee.com/2010/05/sql-server-monitoring-checklist/#comments</comments>
		<pubDate>Mon, 03 May 2010 22:05:10 +0000</pubDate>
		<dc:creator>bradmcgehee</dc:creator>
				<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Database Maintenance]]></category>

		<guid isPermaLink="false">http://www.bradmcgehee.com/2010/05/sql-server-monitoring-checklist/</guid>
		<description><![CDATA[I have worked with a lot of organizations who have just a small handful of SQL Server instances. In most of these cases, these SQL Servers contain mission-critical data, but on the other hand, these organizations are not big enough to justify a full-time DBA, so either they subcontract the DBA work to an outside [...]]]></description>
			<content:encoded><![CDATA[<p>I have worked with a lot of organizations who have just a small handful of SQL Server instances. In most of these cases, these SQL Servers contain mission-critical data, but on the other hand, these organizations are not big enough to justify a full-time DBA, so either they subcontract the DBA work to an outside organization, or they assign someone from within the company to be the a “part-time” DBA.</p>
<p><span id="more-1523"></span></p>
<p>Often, many of these part-time DBAs don’t have the time, or the interest, in learning how to properly maintain the SQL Servers under their management. Because of this, many of these mission-critical SQL Servers are at the brink of disaster, just one small step away from going down, potentially bringing down their organization at the same time.</p>
<p>When I run across such SQL Server instances, I fix up their instances the best I can (there are usually limitations imposed on me on what I can and cannot do), and I do my best to mentor the “part-time DBA” on common best practices. While some of these “part-time DBAs” are eager to learn, many of them don’t always retain everything I tell them. To help overcome this problem, I like to create checklists (cheat sheets) for them so they can better remember what they need to do.</p>
<p>If these part-time DBAs tell me they don’t have the time to follow my checklists (which is often the case), then I will recommend a third-party monitoring tool, such as <a href="http://www.red-gate.com/products/SQL_Response/index.htm?utm_source=bradmcgehee&#038;utm_medium=weblink&#038;utm_content=monitoringlist201005&#038;utm_campaign=sqlresponse" target="_blank">Red Gate Software’s SQL Response monitoring tool</a>, to help them monitor their SQL Servers. SQL Response has the ability to monitor SQL Server instances and alert DBAs to potential problems, and is easy for “part-time” DBAs to implement and use.</p>
<p>While I generally create customized checklists for each organization (as each organization is slightly different), many of the items in my checklists are common to most SQL Servers. For example, one of the checklists I generally prepare is what I call my <strong>Day-to-Day DBA Checklist</strong>, which includes these general suggestions. I recommend that DBAs perform these tasks on a daily basis (or as applicable).</p>
<blockquote><p>1. Make sure each of your production databases are available and accessible to their users.</p>
<p>2. Check all processes &#8211; such as clustering, replication, service broker, log shipping, database mirroring &#8211; to verify that they are running correctly.</p>
<p>3. Check OS, SQL Server, Security, and other logs for unusual events.</p>
<p>4. Verify that all scheduled jobs have run successfully, including checking for long running or &#8220;hung&#8221; jobs.</p>
<p>5. Confirm that backups have been made and successfully saved to a secure location.</p>
<p>6. Monitor disk space to ensure your SQL Servers won&#8217;t run out of disk space. For best performance, all disks should have 15% or more of free space.</p>
<p>7. Throughout the day, periodically monitor SQL Server performance using Performance Monitor, Profiler/SQL Trace, or other performance monitoring tools.</p>
<p>8. Regularly monitor and identify blocking issues.</p>
<p>9. Keep a log of any changes you make to servers, including documentation of any performance issues you identify and correct.</p>
<p>10. Regularly restore backups to a test server in order to verify that you can restore them. You don&#8217;t need to restore all backups every day, but do so often to ensure that you are confident you have good backups.</p>
<p>11. Take some time to learn something new as a DBA to further your professional development.</p>
<p>12. Automate as many of these day-to-day tasks as possible.</p></blockquote>
<p>If you are an experienced DBA, your SQL Server Monitoring list is probably much longer, and you probably automate most of these tasks. Because many of the people I work with are “part-time” DBAs, I chose to keep the list as simple as possible.</p>
<p>So my question to you is, what additional items would you add to my Day-to-Day SQL Server Checklist, keeping in mind that the audience for this list is for “part-time DBAs” without a lot of SQL Server experience?</p>
<blockquote><p><a href="http://www.red-gate.com/products/SQL_Backup/offers/exceptional_dba_awards_2010.htm?utm_source=bradmcgehee&#038;utm_medium=weblink&#038;utm_content=poster201005&#038;utm_campaign=sqlbackupbundle" target="_blank">You can download a free PDF poster version of my Day-to-Day SQL Server Checklist here</a>.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.bradmcgehee.com/2010/05/sql-server-monitoring-checklist/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How Many DBAs Use the Maintenance Plan Wizard/Designer?</title>
		<link>http://www.bradmcgehee.com/2010/03/how-many-dbas-use-the-maintenance-plan-wizarddesigner/</link>
		<comments>http://www.bradmcgehee.com/2010/03/how-many-dbas-use-the-maintenance-plan-wizarddesigner/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 00:44:30 +0000</pubDate>
		<dc:creator>bradmcgehee</dc:creator>
				<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Database Maintenance]]></category>

		<guid isPermaLink="false">http://www.bradmcgehee.com/2010/03/how-many-dbas-use-the-maintenance-plan-wizarddesigner/</guid>
		<description><![CDATA[ When I wrote my most recent free eBook, Brad’s Sure Guide to SQL Server Maintenance Plans, some of the DBAs I know asked me why I wrote it. After all, “real” DBAs don’t use the Maintenance Plan Wizard/Designer built into SQL Server 2005/2008 Management Studio (SSMS) to maintain their databases, they write Transact-SQL or [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.bradmcgehee.com/wp-content/uploads/2010/03/image15.png"><img style="border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" align="left" src="http://www.bradmcgehee.com/wp-content/uploads/2010/03/image_thumb15.png" width="112" height="163" /></a> When I wrote my most recent free eBook, <em><a href="http://www.red-gate.com/products/SQL_Backup/offers/backup_maintenance_plans.htm" target="_blank">Brad’s Sure Guide to SQL Server Maintenance Plans</a></em>, some of the DBAs I know asked me why I wrote it. After all, “real” DBAs don’t use the Maintenance Plan Wizard/Designer built into SQL Server 2005/2008 Management Studio (SSMS) to maintain their databases, they write Transact-SQL or PowerShell scripts instead. The reason I wrote the book is because there are many DBAs, many more than you think, who use this tool.</p>
<p>In a recent survey on my website (<a href="http://www.bradmcgehee.com" target="_blank">www.bradmcgehee.com</a>) I conducted the following poll:</p>
<p><a href="http://www.bradmcgehee.com/wp-content/uploads/2010/03/image16.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.bradmcgehee.com/wp-content/uploads/2010/03/image_thumb16.png" width="306" height="258" /></a>&#160;</p>
<p> <span id="more-1424"></span>
<p>As you can see, 38% of respondents said they use this tool exclusively to create their database maintenance plans, and another 30% said they use it some of the time. This means that 68%, or about two-thirds of all SQL Server users, use the Maintenance Plan Wizard/Designer to build their server’s database maintenance plans. That’s a lot of DBAs. I imagine that most of these 68% are novice DBAs who don’t have a lot of experience using SQL Server and need a quick and easy way to perform database maintenance. On the other hand, I have had some experienced DBAs confide in me that they use the tool for less critical servers when time and convenience are the priority.</p>
<p>And this comes to the crux of why I wrote the book. While the Maintenance Plan Wizard/Designer may appear to be an easy tool to use, this ease of use is very deceptive. In reality, this tool is poorly designed and documented, and it allows novice DBAs to create horrendous maintenance plans that can give some DBAs a false sense of security, in addition to causing more performance problems than they resolve. So the goal of my book is to instruct novice DBAs on how to properly use the tool. Hopefully, once they have gained more experience, they will learn how to write their own maintenance scripts, or use some of the free ones provided on the Internet, such as the scripts provided by <a href="http://www.bradmcgehee.com/2009/11/ola-hallengren-updates-free-database-maintenance-scripts-to-support-sqlbackup-6-3/">Ola Hallengren</a>. </p>
<p>If you have used the Maintenance Plan Wizard/Designer, and have some tips you would like to share, please do so below.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bradmcgehee.com/2010/03/how-many-dbas-use-the-maintenance-plan-wizarddesigner/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Free SQL Server Training Webinar Series</title>
		<link>http://www.bradmcgehee.com/2010/02/free-sql-server-training-webinar-series/</link>
		<comments>http://www.bradmcgehee.com/2010/02/free-sql-server-training-webinar-series/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 22:11:29 +0000</pubDate>
		<dc:creator>bradmcgehee</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[DBA Career]]></category>
		<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Database Maintenance]]></category>
		<category><![CDATA[Speaking Schedule]]></category>

		<guid isPermaLink="false">http://www.bradmcgehee.com/2010/02/free-sql-server-training-webinar-series/</guid>
		<description><![CDATA[
SQLServerCentral.com, PragmaticWorks, and Wrox Press are sponsoring a series of free SQL Server webinars in February. Called the SQL Server 101 Series, the sessions include:

Introduction to Managing a SQL Server Database with Jorge Segarra
Beginning T-SQL with Patrick LeBlanc
The Modern Resume with Steve Jones
How to Become an Exceptional DBA with Brad McGehee
Fundamentals of SQL Server Integration [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.bradmcgehee.com/wp-content/uploads/2010/02/image7.png"><img style="display: inline; border: 0px;" title="image" src="http://www.bradmcgehee.com/wp-content/uploads/2010/02/image_thumb7.png" border="0" alt="image" width="604" height="144" /></a></p>
<p><a href="http://www.sqlservercentral.com/" target="_blank">SQLServerCentral.com</a>, <a href="http://www.pragmaticworks.com/" target="_blank">PragmaticWorks</a>, and Wrox Press are sponsoring a series of free SQL Server webinars in February. Called the <a href="http://www.pragmaticworks.com/resources/webinars/February2010Webinar.aspx" target="_blank">SQL Server 101 Series</a>, the sessions include:</p>
<ul>
<li><span style="font-family: Arial; color: #000000; font-size: x-small;"><strong>Introduction to Managing a SQL Server Database</strong> with Jorge Segarra</span></li>
<li><span style="font-family: Arial; color: #000000; font-size: x-small;"><strong>Beginning T-SQL</strong> with Patrick LeBlanc</span></li>
<li><span style="font-family: Arial; color: #000000; font-size: x-small;"><strong>The Modern Resume</strong> with Steve Jones</span></li>
<li><span style="font-family: Arial; color: #000000; font-size: x-small;"><strong>How to Become an Exceptional DBA</strong> with Brad McGehee</span></li>
<li><span style="font-family: Arial; color: #000000; font-size: x-small;"><strong>Fundamentals of SQL Server Integration Services</strong> with Brian Knight</span></li>
<li><span style="font-family: Arial; color: #000000; font-size: x-small;"><strong>0 to Cube in 60 Minutes (SSAS)</strong> with Adam Jorgensen</span></li>
<li><span style="font-family: Arial; color: #000000; font-size: x-small;"><strong>Troubleshooting SQL Server</strong> with Christian Bolton</span></li>
<li><span style="font-family: Arial; color: #000000; font-size: x-small;"><strong>Introduction to Reporting Services</strong> with Devin Knight</span></li>
</ul>
<p><span style="font-family: Arial; color: #000000;">Sessions run from February 22 through February 26, and most sessions will be offered twice a day to better meet your schedule. <a href="http://www.pragmaticworks.com/resources/webinars/February2010Webinar.aspx" target="_blank">Registration</a> is currently open and is limited to the first 1000 attendees.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bradmcgehee.com/2010/02/free-sql-server-training-webinar-series/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>DBA Checklist Updated</title>
		<link>http://www.bradmcgehee.com/2010/01/dba-checklist-updated/</link>
		<comments>http://www.bradmcgehee.com/2010/01/dba-checklist-updated/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 22:49:13 +0000</pubDate>
		<dc:creator>bradmcgehee</dc:creator>
				<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Database Maintenance]]></category>

		<guid isPermaLink="false">http://www.bradmcgehee.com/2010/01/dba-checklist-updated/</guid>
		<description><![CDATA[I have recently updated and revised my DBA Best Practices Checklist, which is hosted on www.Simple-Talk.com. The goal of the list is not to cover every aspect of SQL Server administration, but to hit the highlights. In addition, not every item in the checklist will apply to every SQL Server instance, under every circumstance. So [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently updated and revised my <a href="http://www.simple-talk.com/sql/database-administration/brads-sure-dba-checklist/" target="_blank">DBA Best Practices Checklist</a>, which is hosted on <a href="http://www.Simple-Talk.com" target="_blank">www.Simple-Talk.com</a>. The goal of the list is not to cover every aspect of SQL Server administration, but to hit the highlights. In addition, not every item in the checklist will apply to every SQL Server instance, under every circumstance. So like any list of SQL Server best practices, don’t forget that they may or may not apply to  your environment.</p>
<p>If you would like to add your own items to the checklist, or to provide other feedback on the checklist, please do so here, and I will try to include your feedback the next time I update the list.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bradmcgehee.com/2010/01/dba-checklist-updated/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Creating the SSC Maintenance Plan: Part 3</title>
		<link>http://www.bradmcgehee.com/2010/01/part-3-creating-the-ssc-maintenance-plan/</link>
		<comments>http://www.bradmcgehee.com/2010/01/part-3-creating-the-ssc-maintenance-plan/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 01:51:13 +0000</pubDate>
		<dc:creator>bradmcgehee</dc:creator>
				<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Database Maintenance]]></category>
		<category><![CDATA[Indexing]]></category>

		<guid isPermaLink="false">http://www.bradmcgehee.com/2010/01/part-3-creating-the-ssc-maintenance-plan/</guid>
		<description><![CDATA[Note: This is an in-depth article that exceeds 5,000 words, and provides a case-study of how a maintenance plan could be implemented on a single, plain vanilla, SQL Server instance.
As I have mentioned in previous parts of this article series (part 1, part 2), I act as a consultant DBA for the SQLServerCentral.com (SSC) and [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Note: This is an in-depth article that exceeds 5,000 words, and provides a case-study of how a maintenance plan could be implemented on a single, plain vanilla, SQL Server instance.</p></blockquote>
<p>As I have mentioned in previous parts of this article series (<a href="http://www.bradmcgehee.com/2009/12/upgrading-the-ssc-sql-servers-part-1/" target="_blank">part 1</a>, <a href="http://www.bradmcgehee.com/2010/01/upgrading-the-ssc-sql-servers-part-2/" target="_blank">part 2</a>), I act as a consultant DBA for the <a href="http://www.sqlservercentral.com/" target="_blank">SQLServerCentral.com</a> (SSC) and <a href="http://www.simple-talk.com/" target="_blank">Simple-Talk.com</a> (ST) backend databases, and I don’t perform any of the day-to-day tasks. But one of the things I was asked to do was to implement a database maintenance plan for the new, two-node, active/active cluster that has recently gone live. In this third part of this series, I am going to talk about how I created the maintenance plan, and why I made the choices I did.</p>
<p><span id="more-1087"></span></p>
<p>To recap some of what I have said in the previous parts of this series, node 1 of the active/active node cluster is dedicated to SSC, while the second node is dedicated to ST. Currently, only the SSC node is in production, while the ST node has yet to go into production. Because of this, the focus of this article is on the maintenance plan for the SSC node.</p>
<p>Before the new cluster was installed, the eight databases that are used to run SSC ran on two different servers, splitting the load between them. This of course meant that there were two SQL Server instances to perform database maintenance on. Backups were handled by Red Gate Software’s <a href="http://www.red-gate.com/products/SQL_Backup/index.htm" target="_blank">SQL Backup Pro</a>, and other database maintenance was done using a Maintenance Plan created with the Maintenance Plan Wizard. Today, with the new server, all eight databases are running on a single node, which means only one database maintenance plan for the SSC databases is needed.</p>
<p>Like the older servers, the new SSC server is being backed up using SQL Backup Pro. This is handled by <a href="http://www.red-gate.com/" target="_blank">Red Gate’s</a> IT department and I don’t get involved in it. I do know they make full backups every night and transaction log backups every 30 minutes. Since I don’t have to worry about backups as part of my maintenance plan, all I had to focus on was database integrity, index maintenance, and a few smaller maintenance tasks.</p>
<p>As I thought about how to best create this maintenance plan, here was what I considered:</p>
<ul>
<li>Although SSC is accessed by DBAs throughout the world 24 hours a day, the SSC databases have a specific pattern of activity. I saw this with the two older servers, but I wasn’t sure if this same pattern would still exist when all of the databases (and their various jobs) were located on a single server. This meant that I would need to reevaluate when the new server was at its lowest point of activity of the day, which would help me determine the optimal maintenance window so that the maintenance job affected as few users as possible when it ran.</li>
<li>As a corollary of the above, I wanted to ensure that my maintenance job didn’t run at the same time as other jobs that run on the server. The SSC databases have a lot of scheduled jobs, some of which are quite resource intensive, and I didn’t want my maintenance job to interfere with any other jobs, causing any potential resource conflicts.</li>
<li>On the old servers, which used a Maintenance Plan created with the Maintenance Plan Wizard, indexes were maintained by rebuilding every index, in every database, every day. This was very resource intensive, especially given that fact that many of the tables have little activity (such as those tables that contain articles and forum posts), and would not benefit from a nightly index rebuild. So my goal for the new maintenance plan was to use a T-SQL script that would review the index fragmentation of each index, and then to either rebuild or reorganize it, depending on its level of fragmentation.</li>
<li>On the old servers, database integrity checks (DBCC CHECKDB) were only run once a week, because the servers were already bottlenecked, and trying to run integrity checks every day would not have been practical. On the new server, my goal, assuming that the new hardware was up to the task, was to run integrity checks every day. My personal philosophy is to run integrity checks daily, if at all possible, as the sooner you discover problems, the sooner you can fix them. Before I could make this decision, I would need more information on the hardware’s performance to see if it was even feasible to perform this task within the available maintenance window.</li>
<li>Because database maintenance is such a common task, and the SSC databases didn’t really have any unique needs, I didn’t want to reinvent the wheel by creating a custom maintenance plan using T-SQL or PowerShell. So my goal was to use a publicly available maintenance script. There are many excellent maintenance scripts available on the Internet, and all I had to do was choose one and implement it according to the server’s needs.</li>
<li>Since I am not the day-to-day production DBA of the SSC databases, I needed to keep the maintenance plan as simple as possible, and at the same time, document it as much as possible so that the IT staff at Red Gate could easily understand what I did.</li>
</ul>
<p>The above list doesn’t include everything I considered before putting together the SSC database maintenance plan, but it does cover the key points.</p>
<blockquote><p>Note: The SSC databases are running under SQL Server 2008 Standard Edition, SP1. If you decide to imitate my maintenance plan for your own SQL Server instances, keep in mind that all the choices I made are based on this version of SQL Server, and may or may not apply to other editions or versions of SQL Server.</p></blockquote>
<h2>Identifying Which Maintenance Tasks to Perform</h2>
<p>After taking into consideration my general goals for this maintenance plan, my first step was to determine exactly what database maintenance I wanted to perform on the SSC databases. I ended up deciding to perform these maintenance tasks:</p>
<ul>
<li><strong>Run integrity checks on all system and production databases on a daily basis using the DBCC CHECKDB command</strong>. While my goal was to perform this task daily, as I mentioned earlier, I wasn’t sure if this was practical or not, as this was a new server, and the number of databases on the server had increased. The only way to really find out if this was practical or not was to try it. After some experimentation, I discovered that it was indeed practical to perform this task daily. With the new hardware, performing an integrity check now only takes about 10 minutes for all system and production databases, which is well within my maintenance window. In addition, the new server no longer has any CPU or I/O bottlenecks, so running the resource intensive DBCC CHECKDB command has little or no affect on people who access SSC during the brief time while this maintenance task is running.</li>
<li><strong>To either rebuild, or to reorganize, all tables in all production databases that have become significantly fragmented, on a daily basis</strong>. The topic of index maintenance is a large one, and a topic that I don’t want to spend a lot of time on here. Based on my past experience with index maintenance, here’s what I decided to do: If an index has less than 5% fragmentation, or if the total size of the index is less than 100 pages, leave it alone. If index fragmentation is 5% or more, but less than 20%, the run ALTER INDEX REORGANIZE and UPDATE STATISTICS on it. If index fragmentation is greater than 20%, the run ALTER INDEX REBUILD on it.There isn’t any magic number to use when deciding when you should or should not rebuild or reorganize an index. BOL (Books Online) makes a slightly different recommendation than what I have chosen, but the recommendation in BOL is only a very general recommendation, and you should choose options that work best for your databases. I experimented with these numbers, testing several different combinations until I found the one above, which seemed to be a good balance between index optimization and the amount of time and resources it takes to maintain them. Given that users access the SSC databases 24/7, you might ask why I choose to use ALTER INDEX REBUILD at all, given that this command will lock a table while it is working, preventing access until it is done? I made this choice because it is more effective than ALTER INDEX REORGANIZE on large, heavily fragmented tables, and because only a few tables are affected each day, and I only run the command during the least busy time of the day. It is possible that a few users might be negatively affected by this, but it won’t be by much. It would be better if we had the Enterprise Edition of SQL Server and could perform an online rebuild, but since we don’t, this is a compromise I am willing to make. I’ll watch over the database’s performance over time, and depending on what I see, I might tweak some of these options if needed. This particular job only takes 2-3 minutes every day.</li>
<li><strong>Delete older job and backup history from the msdb database on a regular basis</strong>. Over time, the MSDB database can grow very large if older job and backup history information is not removed. Typically, I schedule a job to run once a week to remove older entries (older than 60 days) using the sp_delete_backuphistory and the sp_purge_jobhistory commands. If I did this on the SSC server, then I would have to create two separate jobs: a daily job for database integrity checks and index optimization, and a weekly job to remove the old job and backup history. For this particular server, I made a different choice. Because other IT staff would be performing the day-to-day management of the databases, I decided to keep things very simple and create a single job that performs all of these tasks on a daily basis. While it isn’t necessary to run the sp_delete_backuphistory and the sp_purge_jobhistory commands daily, there really isn’t any downside to doing this on this server, as running both commands takes less than one second each day.</li>
</ul>
<p>Now that I had decided what I wanted to do, the next step was to implement it, and before I could do that, I needed to decide on what scripts to use to perform the database maintenance tasks.</p>
<blockquote><p>Note: I could have easily added database and log backup to my maintenance plan, but I did not have to because this was being handled separated by Red Gate’s IT staff using SQL Backup Pro.</p></blockquote>
<h2>Deciding Which Maintenance Scripts to Use</h2>
<p>As I mentioned earlier, because the database maintenance I needed to perform on the SSC databases is very vanilla, I didn’t see much point in creating a custom script to perform it. Many DBAs have written scripts to perform the above tasks, and have shared them with the SQL Server community. Since I have reviewed many of these scripts over the years, I knew right away which one I wanted to use, and that is the free T-SQL database maintenance scripts written by Ola Hallengren, which are available from <a href="http://ola.hallengren.com" target="_blank">ola.hallengren.com</a>.</p>
<p>Ola offers several different scripts, that when run, create stored procedures in the master database, which when used with the appropriate parameters, can perform a wide variety of database maintenance.</p>
<p>Ola’s main database maintenance script (MaintenanceSolution.sql), when it is run, will automatically create all the necessary stored procedures (and one function), along with all the jobs you need to run them. All you have to do is to schedule the jobs, and you are off and running, assuming that you want to accept all of Ola’s default settings and jobs.</p>
<p>Personally, I don’t use Ola’s MaintenanceSolution.sql script. Instead, I use his separate scripts, which he provides if you only want to pick and choose what database maintenance stored procedures you want to use. These separate scripts are named:</p>
<ul>
<li>DatabaseBackup.sql</li>
<li>DatabaseIntegrityCheck.sql</li>
<li>IndexOptimize.sql</li>
</ul>
<p>In this particular case, I decided to use Ola’s DatabaseIntegrityCheck.sql and IndexOptimize.sql scripts, as I was not concerned about backups in my maintenance plan. Another reason I used his individual scripts was that I like to make a few changes to them, which is easy to do, as Ola has made the scripts easy to modify. And the last reason I used these individual scripts is that I prefer to create my own jobs, instead of using the ones that are automatically created if you use Ola’s MaintenanceSolution.sql script. These are just personal choices, as you can run Ola’s scripts just as they are, and they will meet the needs of many DBAs without any changes.</p>
<p>One thing that Ola’s scripts do not perform is the removal of old job and backup history from the msdb databases. In this case, I had to write my own, very simple T-SQL script, to accomplish this task.</p>
<p>In the next section, I will explain in more detail how I created the SSC database maintenance plan using Ola’s two stored procedures, and my simple T-SQL script.</p>
<h2>Creating the Maintenance Jobs</h2>
<p>Given everything I have talked about so far, essentially, I needed to create a SQL Server Agent Job that had three steps, which include:</p>
<ul>
<li><strong>Step #1</strong>: Run Ola’s DatabaseIntegrityCheck stored procedure</li>
<li><strong>Step #2</strong>: Run Ola’s IndexOptimize stored procedure</li>
<li><strong>Step #3</strong>: Run my T-SQL code to remove old job and backup data from the MSDB database</li>
</ul>
<p>Let’s look at each of these, one step at a time.</p>
<blockquote><p>Note: I’m not going to try and duplicate <a href="http://ola.hallengren.com/Documentation.html" target="_blank">Ola’s documentation</a> in this article. If you have specific questions about how Ola’ scripts work, please visit his website and read his documentation.</p></blockquote>
<h2>Job Step #1</h2>
<p>My first step was to run Ola’s DatabaseIntegrityCheck.sql script. But before I did, I checked to see what default settings he used to perform the database integrity checks. The available options are show below:</p>
<p><a href="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image0021.jpg"><img style="display: inline; border: 0px;" src="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image002_thumb1.jpg" border="0" alt="" width="604" height="206" /></a></p>
<p>You can accept the default settings you see above, or you can make changes if you like. If you want to make any changes, you will need to make them to the original T-SQL script (DatabaseIntegrityCheck.sql) before you create the stored procedure. After reviewing the above options, I decided to accept Ola’s default settings, so I didn’t have to alter the script. I just ran it, and the DatabaseIntegrityCheck stored procedure was created in the master database.</p>
<p>My next step was to create a new SQL Server Agent Job, and add the above stored procedure as its first step, which you see below.</p>
<p><a href="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image0041.jpg"><img style="display: inline; border: 0px;" src="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image004_thumb1.jpg" border="0" alt="" width="539" height="492" /></a></p>
<p>Notice, that when I run this step as part of a larger, single job, that it is run as a CmdExec job type, and that the stored procedure actually runs from SQLCMD. Since you can’t see all of the code above, here is what it looks like:</p>
<blockquote><p>sqlcmd -E -S $(ESCAPE_SQUOTE(SRVR)) -d master -Q &#8220;EXECUTE [dbo].[DatabaseIntegrityCheck] @Databases = &#8216;ALL_DATABASES&#8217;&#8221; –b</p></blockquote>
<p>While I’m not going to discuss how to use SQLCMD, what I do want to point out is the parameter that is being passed to the DatabaseIntegrityCheck stored procedure above. In this case, it is “All_DATABASES”. All of Ola’s stored procedures allow you to specify what databases they are to run against. I have chosen to run this stored procedure against all databases on the server (system and user). Other choices that are available include those listed below.</p>
<p><a href="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image0061.jpg"><img style="display: inline; border: 0px;" src="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image006_thumb1.jpg" border="0" alt="" width="186" height="118" /></a></p>
<p>Another key point about this job step is the logging, which I want to show you. If you look at the “Advanced” screen of the “Job Step Properties” screen, you see the following:</p>
<p><a href="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image0081.jpg"><img style="display: inline; border: 0px;" src="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image008_thumb1.jpg" border="0" alt="" width="545" height="493" /></a></p>
<p>Note above the “Output file”, which looks like this in its entirety:</p>
<blockquote><p>S:\Program Files\Microsoft SQL Server\MSSQL10.INS1\MSSQL\Log\DatabaseIntegrityCheck_$(ESCAPE_SQUOTE(JOBID))_$(ESCAPE_SQUOTE(STEPID))_$(ESCAPE_SQUOTE(STRTDT))_$(ESCAPE_SQUOTE(STRTTM)).txt</p></blockquote>
<p>The above path and filename will automatically create a log file with a unique name, so that you can easily identify the job log, and open it up in order to see exactly what it does. For example, below is a partial example of what the job log looks like:</p>
<p><a href="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image0101.jpg"><img style="display: inline; border: 0px;" src="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image010_thumb1.jpg" border="0" alt="" width="601" height="494" /></a></p>
<p>The above output is created by Ola’s stored procedure, and is great for seeing exactly what is going on after the job is executed.</p>
<h2>Job Step #2</h2>
<p>My second job step was to run Ola’s IndexOptimize stored procedure. While Ola’s DatabaseIntegrityCheck stored procedure has only a few option, the IndexOptimize stored procedure has a large numbers of options to consider. Since there are so many options, I am going to first show you the options are, then I will show you what options I selected, and talk a little about why I chose the options I did. For a detailed explanation of what each option does, visit Ola’s <a href="http://ola.hallengren.com/Documentation.html" target="_blank">documentation page</a>.</p>
<p><a href="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image0121.jpg"><img style="display: inline; border: 0px;" src="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image012_thumb1.jpg" border="0" alt="" width="579" height="493" /></a></p>
<p>The screen above will probably look a little confusing at first, as there is a lot of information to take in. The first column describes different levels of index fragmentation. For example, FragmentationHigh_LOB refers to indexes that have a high level of fragmentation and also include LOB objects. If you look at each of the options in the first column, it should become self-evident; quite quickly, what each option means. On the other hand, what exactly does High, Medium, and Low mean? I will save a discussion on what these mean a little later. For now, all you need to know is that they refer to levels of index fragmentation that you can configure.</p>
<p>The second column is a brief description, and should be self-explanatory.</p>
<p>On the other hand, the last column is not as self-explanatory. In each of the boxes of the third column is a list of possible actions that can potentially occur for a level of fragmentation that exists. For example, the first row, which is for FragmentationHigh_LOB, has five different possible actions listed in the third column. What this means is that if the FragmentationHigh_LOB level of fragmentation is identified for a particular index, that you can choose to have one of five potential actions to happen to the index. The default action is “INDEX_REBUILD_OFFLINE”. If nothing is changed, this means that when an index is identified as having high fragmentation, and it also includes LOB objects, then the “INDEX_REBUILD_OFFLINE” action will take place on the index. As you can probably deduce, this action causes the index to be rebuilt using the ALTER INDEX REBUILD command (offline, as opposed to the online REBUILD option available with the Enterprise Edition of SQL Server). If you don’t want the “INDEX_REBUILD_OFFLINE” action to occur when high fragmentation on an index with LOB objects in it is identified, then you can choose from the remaining four choices. See Ola’s documentation for a more detailed information on what each action does.</p>
<p>Besides the above available actions, there are additional settings you can leave at their default value, or change to meet your database’s needs. See the chart below.</p>
<p><a href="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image0141.jpg"><img style="display: inline; border: 0px;" src="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image014_thumb1.jpg" border="0" alt="" width="423" height="493" /></a></p>
<p>Except for the first two options above, most of the other options should be familiar to experienced DBAs. So let’s briefly discuss what the first two options do. Earlier, I mentioned that index fragmentation is divided into High, Medium, and Low in the IndexOptimize stored procedure. If you like, you can use the top two setting to determine what High, Medium, and Low mean. For example, the FragmentationLevel1 option above is used to set the Low level of fragmentation. By default, if the fragmentation of an index is below 5%, then it is considered to have a Low fragmentation level. The FragmentationLevel2 option is used to set the High level of fragmentation. By default, if the fragmentation of an index is greater than 30%, then it is considered to have a High fragmentation level. If the fragmentation falls between these two numbers (5% and 30%), then the fragmentation level is considered to be Medium. You can use the default values as established by Ola, or you can change the settings to meet your needs. His settings are based on general recommendations as published in BOL.</p>
<blockquote><p>To review, the High, Medium, and Low levels refers to different levels of index fragmentation, and Ola’s script uses this to determine what action to take on the index, based on the index’s level of fragmentation.</p></blockquote>
<p>So what options did I choose? Below you will see a snippet of code from the IndexOptimize stored procedure. This is where you can modify the default setting, if you like.</p>
<p><a href="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image0161.jpg"><img style="display: inline; border: 0px;" src="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image016_thumb1.jpg" border="0" alt="" width="604" height="289" /></a></p>
<p>Towards the top part of the code, I specify what action I want to occur at different levels of fragmentation. For example, if an index is identified by the code as “FragmentationHigh_LOB”, I want the “INDEX_REBUILD_OFFLINE” action to be performed, and so on.</p>
<p>After deciding what actions you want to be performed on the different levels of fragmentation, you have the opportunity to determine the FragmentationLevel1 and FragmentationLevel 2 values, which determine the boundaries of High, Medium, and Low Fragmentation. For the SSC databases, I have changed the FragmentationLevel2 from its default value of 30% to 20%. I did this because I wanted to lower the point where an ALTER INDEX REBUILD occurs instead of an ALTER INDEX REORGANIZE. Based on my settings, if an index has less than 5% fragmentation, nothing is done to the index. If the index is between 5% and 20% fragmented, then the ALTER INDEX REORGANIZE and the UPDATE STATISTICS commands are executed. And if index fragmentation is above 20%, then the ALTER INDEX REBUILD command is executed on the index.</p>
<p>Another interesting setting is the “PageCountlevel”. What this means is if the number of pages used for the index is below the assigned value, that the index will be ignored. This is done because removing fragmentation on smaller indexes is rarely beneficial. By not defragmenting smaller indexes, fewer indexes need defragmenting, reducing the time it takes to run the job, and helping to save server resources. The default value is 1000 pages, but I have changed this to 100 for my job. The default value of 1000 comes from an old Microsoft whitepaper, and is a commonly accepted value. On the other hand, I feel that 100 is a better value, based on my own experienced, and from talking with other DBAs I trust. What value is best for you? You will have to make that decision yourself. By choosing the smaller value of 100, instead of the default value of 1000, this means my maintenance script will have to work a little harder. Based on some experimentation I did on the SSC databases using different “PageCountLevels”, I believe this is the sweet spot for this server. It may or may not be for your server.</p>
<p>While there are a lot more options available, I only want to point out one other, and that is the “SortInTempdb” setting. The default value is no, but I have turned it yes. Why? Because by moving much of the work of rebuilding indexes onto tempdb, this can help to reduce the load on your server’s I/O system, provided that your tempdb database is located on its own dedicated spindles, which is true for the SSC server. If your tempdb is located with all of your other databases, then I would recommend that you not turn this option on, as it probably won’t provide you with any performance advantages.</p>
<p>Once I made all of my changes to the original script, I ran it and the IndexOptimize stored procedure was created in the master database, and now I was ready to add it as step #2 of my SQL Server Agent Job, which you see below.</p>
<p><a href="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image0181.jpg"><img style="display: inline; border: 0px;" src="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image018_thumb1.jpg" border="0" alt="" width="540" height="493" /></a></p>
<p>As with the previous stored procedure, this one will be executed using the SQLCMD command, like this:</p>
<blockquote><p>sqlcmd -E -S $(ESCAPE_SQUOTE(SRVR)) -d master -Q &#8220;EXECUTE [dbo].[IndexOptimize] @Databases = &#8216;USER_DATABASES&#8217;&#8221; –b</p></blockquote>
<p>When I created step #1 of the job to check for database integrity, I specified that “ALL_DATABASES” be checked. In step #2 of this job, where I am optimizing my indexes, I am only performing this step on user database, not system databases. This is because system databases rarely will benefit from any index optimization. Because of this, the above command uses the “USER_DATABASES” parameter of the IndexOptimize stored procedure.</p>
<p>Similar to step #1, step #2’s “Advanced” tab of the “Job Step Properties” screen is almost identical. The only change is the output file, which has been slightly modified to indicate that this report will be for the IndexOptimize step.</p>
<blockquote><p>S:\Program Files\Microsoft SQL Server\MSSQL10.INS1\MSSQL\Log\IndexOptimize_$(ESCAPE_SQUOTE(JOBID))_$(ESCAPE_SQUOTE(STEPID))_$(ESCAPE_SQUOTE(STRTDT))_$(ESCAPE_SQUOTE(STRTTM)).txt</p></blockquote>
<p>The above path and filename will automatically create a log file with a unique name, so that you can easily identify and view the job log. For example, below is a partial example of what the job log looks like:</p>
<p><a href="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image0201.jpg"><img style="display: inline; border: 0px;" src="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image020_thumb1.jpg" border="0" alt="" width="604" height="484" /></a></p>
<p>The above output is created by Ola’s stored procedure, and is great for seeing exactly what is going on after the job is executed.</p>
<h2>Job Step #3</h2>
<p>The last step in my SQL Server Agent Job is to remove the older job and backup history from the msdb database. As I mentioned earlier, Ola’s script doesn’t have this feature, so wrote a very simple script to perform this simple task. Below shows the screen for job step #3.</p>
<p><a href="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image0221.jpg"><img style="display: inline; border: 0px;" src="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image022_thumb1.jpg" border="0" alt="" width="539" height="492" /></a></p>
<p>Unlike the first two job steps, this step uses the T-SQL job type and runs several lines of code against the msdb database. All the script does is to subtract 60 days from today’s date, and then uses this date as the cutoff date to remove older job and backup history using the sp_delete_backuphistory and the sp_purge_jobhistory system stored procedures.</p>
<p>Similar to previous two steps “Advanced” tab of the “Job Step Properties” screen, I have specified that the output of this command be written to a file. The only difference in the code is that I have specified that this is for the DeleteHistory step.</p>
<blockquote><p>S:\Program Files\Microsoft SQL Server\MSSQL10.INS1\MSSQL\Log\DeleteHistory_$(ESCAPE_SQUOTE(JOBID))_$(ESCAPE_SQUOTE(STEPID))_$(ESCAPE_SQUOTE(STRTDT))_$(ESCAPE_SQUOTE(STRTTM)).txt</p></blockquote>
<p>The output shows, if any, how many history entries were deleted.</p>
<h2>The SQL Server Agent Job is Done</h2>
<p>Once all of the steps have been to the job, it looks like this.</p>
<p><a href="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image0241.jpg"><img style="display: inline; border: 0px;" src="http://www.bradmcgehee.com/wp-content/uploads/2010/01/clip_image024_thumb1.jpg" border="0" alt="" width="604" height="406" /></a></p>
<p>As with any job, I also specified the actions to be taken should each step fail or succeed, and to set up notifications. Of course, after creating the job, I tested it thoroughly to ensure that everything was working as I expected. As I performed my testing, I also took note of how long the entire job ran, as I needed to know this for the next step.</p>
<h2>Deciding When to Run the Maintenance Jobs</h2>
<p>Now that the job was done, I needed to schedule the job. The first step was to find out how long the job ran. After running the job several times, I found that the job typically took from 10-15 minutes to run. This means that I only needed a 15 minute daily maintenance window to run this job every day. Of course, I made the assumption that it was possible that some days might take longer than 15 minutes, and took this into consideration when determining when to run the job.</p>
<p>As I mentioned earlier in this article, my goal was to identify the least busy time of the day to run the job, and at the same time, ensure that my job did not interfere with any other jobs. To do this, I used the SQL Server 2008 Performance Data Collector.</p>
<p>As many of you may know, the Performance Data Collector has the ability to collect performance data on SQL Server 2008 instances, and store them in a database for later reporting. I used this feature in order to determine the optimal maintenance window in order to run the maintenance job. Of course, before I could collect any useful data, the SSC server had to be in production. On the other hand, I really needed to perform database maintenance on a daily basis, even before I had an opportunity to collect any historical performance data from the Performance Data Collector. So, once the new SSC SQL Server instance went into production, I had to make an educated guess as to when to run the maintenance plan, and then wait several weeks before I felt I had enough data to be able to identify the lowest point of activity during the day, which would be the ideal time to run the maintenance plan with the least amount of impact on users of the website.</p>
<p>After reviewing server activity on the SSC SQL Server instance for several weeks, I was able to determine that the least busiest times of the day fell consistently between 5:00 PM and 7:00 PM Mountain Standard Time (MST). MST is used for the SSC server because Steve Jones, editor for SSC, lives in this time zone, although the physical server is located in London. So now, I only had to select a time period within this time range where the approximately 15 minute long job could run.</p>
<blockquote><p>Note: I also compared the activity on the SSC server to the Google Analytics data, which confirmed that this time range had the lowest number of page views of the day, based on worldwide activity.</p></blockquote>
<p>I ended up selecting 6:35 PM MST as the time to run the job, for several reasons. First, 6:35 PM MST is 5:30 PM PST, which means that most of the people in North America (SSC’s biggest audience) would most likely be home, and less likely to be accessing the SSC website. Second, there were no other jobs on the SSC server running between 6:31 PM MST and 6:59 PM MST, which means my job would not interfere with any other jobs. And third, this would give the typically 15 minute job a cushion of 10 minutes should it happen to run longer than usual, without interfering with a job that starts at 7:00 PM MST.</p>
<h2>Checking How the Job Affects the Server’s Performance</h2>
<p>Once I scheduled the job to begin running at 6:35 PM MST, I also spent a few days, watching to the performance of the job using the Performance Data Collector, just to see if it created any potential problems as it ran. After checking for several days after running the maintenance job at this time, there was a spike in CPU and disk I/O, as to be expected, but not enough to cause any bottlenecks. About the only time a user might experience any slowdown when accessing SSC would be during the 2-3 minutes it takes to optimize the indexes, and only if an index should be rebuilt, and not reorganized. Of course, I will be checking these jobs weekly to see if there is any need for changes to the plan.</p>
<p>As you might well imagine, this is not all of the database maintenance the SSC databases needs, but it does cover some of the key daily tasks that can easily be automated.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bradmcgehee.com/2010/01/part-3-creating-the-ssc-maintenance-plan/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>What Would You Like to See in a New Book on Indexing?</title>
		<link>http://www.bradmcgehee.com/2010/01/what-would-you-like-to-see-in-a-new-book-on-indexing/</link>
		<comments>http://www.bradmcgehee.com/2010/01/what-would-you-like-to-see-in-a-new-book-on-indexing/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 19:20:25 +0000</pubDate>
		<dc:creator>bradmcgehee</dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Database Maintenance]]></category>
		<category><![CDATA[Indexing]]></category>

		<guid isPermaLink="false">http://www.bradmcgehee.com/2010/01/what-would-you-like-to-see-in-a-new-book-on-indexing/</guid>
		<description><![CDATA[I am currently in the early stages of writing an outline for a new book on indexing, targeted towards novice DBAs. While this topic has been done to death in hundreds of articles, presentations, and books, I think there is still room for a book that makes the topic easy to read and easy to [...]]]></description>
			<content:encoded><![CDATA[<p>I am currently in the early stages of writing an outline for a new book on indexing, targeted towards novice DBAs. While this topic has been done to death in hundreds of articles, presentations, and books, I think there is still room for a book that makes the topic easy to read and easy to understand for beginners. The focus on the book would be on the essential (not esoteric) indexing skills that DBAs need to perform their job on a day-to-day basis.</p>
<p>I would really appreciate your advice and feedback on what such a book should include. For example:</p>
<ul>
<li><span style="font-family: Arial; color: #000000; font-size: x-small;">What part(s) of indexing do you find <em>very easy</em> to understand?</span></li>
<li><span style="font-family: Arial; color: #000000; font-size: x-small;">What part(s) of indexing do you find the <em>most difficult</em> to understand?</span></li>
<li><span style="font-family: Arial; color: #000000; font-size: x-small;">What topics do you think I should include in the book that would be of the most help to you?</span></li>
<li><span style="font-family: Arial; color: #000000; font-size: x-small;">What topics do you think I should <em>not</em> include in the book because they are not helpful for the typical DBA?</span></li>
<li><span style="font-family: Arial; color: #000000; font-size: x-small;">Can you provide me URL’s of articles on indexing that you think are particularly good, or particularly bad?</span></li>
<li><span style="font-family: Arial; color: #000000; font-size: x-small;">What’s the best book you have ever read on indexing? What’s the worst book? And why?</span></li>
</ul>
<p>If you have any feedback on any of the above topics (you don’t have to answer all of the above question), please post them below. The more feedback I get, the better I will be able to write a book that will best fit the needs for novice DBAs. Once the book is done, it would become freely available as an eBook, just as all my recent books have been.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bradmcgehee.com/2010/01/what-would-you-like-to-see-in-a-new-book-on-indexing/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Free eBook on SQL Server Maintenance Plans Now Available</title>
		<link>http://www.bradmcgehee.com/2010/01/free-ebook-on-sql-server-maintenance-plans-now-available/</link>
		<comments>http://www.bradmcgehee.com/2010/01/free-ebook-on-sql-server-maintenance-plans-now-available/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 21:30:34 +0000</pubDate>
		<dc:creator>bradmcgehee</dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Database Maintenance]]></category>

		<guid isPermaLink="false">http://www.bradmcgehee.com/2010/01/free-ebook-on-sql-server-maintenance-plans-now-available/</guid>
		<description><![CDATA[My new eBook, Brad’ Sure Guide to SQL Server Maintenance Plans is now available as a free, 269 page PDF eBook. The book is designed for part-time or novice DBAs who want to learn how to properly create Maintenance Plans using the tools that come with SQL Server Management Studio (SSMS) in SQL Server 2005/2008.
These [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.bradmcgehee.com/wp-content/uploads/2010/01/BRAD_MAINTENENCE_PLANS_135.gif"><img style="margin: 0px 10px 0px 0px; display: inline; border: 0px;" title="BRAD_MAINTENENCE_PLANS_135" src="http://www.bradmcgehee.com/wp-content/uploads/2010/01/BRAD_MAINTENENCE_PLANS_135_thumb.gif" border="0" alt="BRAD_MAINTENENCE_PLANS_135" width="109" height="139" align="left" /></a>My new eBook, <em><a href="http://www.red-gate.com/products/SQL_Backup/offers/backup_maintenance_plans.htm?utm_source=sqlaloha&amp;utm_medium=blogpost&amp;utm_content=maintenance201001&amp;utm_campaign=sqlbackup" target="_blank">Brad’ Sure Guide to SQL Server Maintenance Plans</a></em> is now available as a free, 269 page PDF eBook. The book is designed for part-time or novice DBAs who want to learn how to properly create Maintenance Plans using the tools that come with SQL Server Management Studio (SSMS) in SQL Server 2005/2008.</p>
<p>These two tools include:</p>
<ul>
<li><strong>Maintenance Plan Wizard</strong> – a Wizard that steps the user through the process of setting up basic Maintenance Plans, with limited options.</li>
<li><strong>Maintenance Plan Designer</strong> – a drag-and-drop GUI interface in SSMS that facilitates the design and creation of more flexible, customizable maintenance plans.</li>
</ul>
<p>Unfortunately, neither tool is especially easy to use or well documented. However, with the guidance I provide in this book, they can become powerful tools in helping the novice DBA to perform critical maintenance tasks, and so help to ensure SQL Server&#8217;s performance and availability. In addition to learning how to use these tools you will, along the way, pick up a lot of good, general advice on SQL Server database maintenance. I also tell you when <em>not</em> to use these tools, as there are many cases when it is more appropriate to use T-SQL or PowerShell scripts to perform database maintenance.</p>
<p>If you get a chance to read the book, please post your feedback here. While I spent a lot of time trying to include as much content as I could, I realize that I did not cover every possible way to use these tools, nor cover how they should be used under every possible SQL Server environment.</p>
<p>A paperback version of the book should become available at Amazon.com within the 60 days.</p>
<p>PS: If you haven’t read my blog on <a href="http://www.bradmcgehee.com/2010/01/a-time-and-a-place-for-the-sql-server-maintenance-plan-wizard/" target="_blank">A Time and Place for the SQL Server Maintenance Plan Wizard</a>, please do so. It explains why I decided to write this book.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bradmcgehee.com/2010/01/free-ebook-on-sql-server-maintenance-plans-now-available/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
