Brad’s Sure Guide to SQL Server Maintenance Plans- P11 docx

5 303 0
Brad’s Sure Guide to SQL Server Maintenance Plans- P11 docx

Đang tải... (xem toàn văn)

Thông tin tài liệu

Chapter 3: Getting Started with the Maintenance Plan Wizard 51 Scheduling Maintenance Tasks Once you've started the Wizard and are past the splash screen (assuming someone hasn't already helpfully ticked the Do not show this starting screen again box), you'll arrive at the Select Plan Properties screen, shown in Figure 3.3. Figure 3.3: This screen is not as simple as you might think. At first glance, the Select Plan Properties screen appears deceptively simple. In fact, it requires making an important choice that has significant implications later on. Let's examine this screen, one part at a time. The first thing we need to do is to give our Maintenance Plan a name. The default name is "MaintenancePlan" but I strongly advise you to change this to something more descriptive of what the plan will do, and/or the databases it will affect. You and other DBAs must be able to distinguish one Maintenance Plan from another. Chapter 3: Getting Started with the Maintenance Plan Wizard 52 To change the name of an existing plan… …Simply right-click on the plan in SSMS object explorer, and select the Rename option. Next, we can add a description of your plan. This is optional, but it can be helpful to self- document the purpose of the plan. Now, we arrive at the important choice I referred to just a moment ago. We need to choose between two options: Separate schedules for each task or Single schedule for the entire plan or no schedule. Notice that the second option is selected by default. If you make the wrong decision now, and later change your mind about which option you want to use, you will have to delete your existing Maintenance Plan and recreate it from scratch (or you could correct the problem with the Maintenance Plan Designer, but it's a lot of work). To help you determine which option you should select for your Maintenance Plan, I first need to explain what each option does. Single Schedule or No Schedule This is the default option and, if you choose it, all the tasks you create in your Maintenance Plan will be scheduled to run as a group, one after another, based on a single schedule of your choice. For example, if you schedule your Maintenance Plan to run once a week, then all the tasks you have selected for the Maintenance Plan will run only once a week. You can also select this option if you want to create a Maintenance Plan, but not schedule it, which allows you to manually run the Maintenance Plan instead. If you are intending to do as many database maintenance tasks as possible in a single Maintenance Plan, the Single Schedule option is not a good choice because it will not allow you to perform different tasks at different times. For example, a task such as rebuilding indexes may only be run once a week, whereas full backups should be performed daily, and transaction log backups hourly. While you could overcome this problem by creating multiple Maintenance Plans for each task, using a different schedule each time, this would, in effect, be the same as choosing the Separate schedules for each task option, only with a greater number of plans to manage. In short, I recommend that you don't select this option. However, its one redeeming feature is that it insures that only one maintenance task runs at a time, so it prevents the potential problem of overlapping tasks, which could result in your SQL Server slowing down. This is harder to achieve using the Separate schedules for each task covered next, but it can certainly be done. Chapter 3: Getting Started with the Maintenance Plan Wizard 53 Separate Schedules for each Task With this preferred option, the Wizard allows you to schedule each maintenance task independently. The inevitable downside, of course, is that it requires a little more work to determine an appropriate schedule for each task. For example, you will need to schedule when a task will execute, how often it executes, and very importantly, make sure you don't accidently schedule all the maintenance tasks to run at the same time, or to overlap each other. Scheduling is a manual process that is not always easy. However, it is perfectly feasible to prevent maintenance tasks from overlapping, when using this option, as I will demonstrate in the following chapters. Based on the discussion up to this point, Figure 3.4 shows you the options I have selected. Figure 3.4: Once the Select Plan Properties page is complete, click on Next. The reason I gave this plan the name User Database Maintenance Plan is because I generally prefer to perform maintenance on user and system databases separately. Although this is not Chapter 3: Getting Started with the Maintenance Plan Wizard 54 required, I choose to separate user and system database Maintenance Plans because the tasks I perform on them are somewhat different, and using two Maintenance Plans, instead of one, gives me more flexibility in the tasks I choose. Notice that I also added a brief description, for documentation purposes, and selected Separate schedules for each task. In addition, note that the Schedule option is now grayed out because it is only applicable if Single schedule for the entire plan or no schedule is chosen. Overview of Maintenance Tasks Having established you plan properties, click Next and you'll arrive at the Select Maintenance Tasks screen, shown in Figure 3.5. Figure 3.5: If you don't choose the correct maintenance tasks, you could create a Maintenance Plan that hurts your server's performance. Chapter 3: Getting Started with the Maintenance Plan Wizard 55 I know of novice DBAs who see the screen in Figure 3.5 and think to themselves, "I'm not sure what all these options mean, so I am going to choose them all, as more must be better than less." Wrong. While the Maintenance Plan Wizard gives you the option of selecting all eleven of the maintenance tasks it offers, doing so can use server resources unnecessarily, and hurt its performance. We will learn a little of why this is true in this chapter, and then expand on the topic in subsequent chapters. Up until this point I have been referring frequently to Maintenance Plan "tasks," but I have yet to explain what they really are, although I assume you have a general idea of what I have been talking about. Now, we get to find out what they are, and what they do. A database maintenance task is simply a specific activity performed as part of a Maintenance Plan. I will offer a brief description of these tasks now, so you get an idea of what each task does, but I'll save the details for upcoming chapters. In fact, following this chapter, are dedicated chapters on each of the following eleven maintenance tasks. Check Database Integrity The Check Database Integrity task runs DBCC CHECKDB against selected databases and performs an internal consistency check on them to see if there are any problems with their integrity. While this task is very resource intensive, it is critical that you perform it on a regular basis, to ensure that your databases aren't damaged. Shrink Database Never use the Shrink Database task. Is that clear enough advice? While we will discuss why it is not a good idea to automatically shrink a database in Chapter 6, the point to keep in mind is that, if you ever need to shrink a database, it should be done manually. Rebuild Index The Rebuild Index task runs the ALTER INDEX statement with the REBUILD option on indexes in the selected databases, by physically rebuilding indexes from scratch. This removes index fragmentation and updates statistics at the same time. If you use this option, you do not want to run the Reorganize Index or the Update Statistics task, as doing so would be redundant. . time. The first thing we need to do is to give our Maintenance Plan a name. The default name is "MaintenancePlan" but I strongly advise you to change this to something more descriptive. for the Maintenance Plan will run only once a week. You can also select this option if you want to create a Maintenance Plan, but not schedule it, which allows you to manually run the Maintenance. need to schedule when a task will execute, how often it executes, and very importantly, make sure you don't accidently schedule all the maintenance tasks to run at the same time, or to overlap

Ngày đăng: 04/07/2014, 23:20

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan