1. Trang chủ
  2. » Công Nghệ Thông Tin

Brad’s Sure Guide to SQL Server Maintenance Plans- P25 doc

5 178 0

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

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 5
Dung lượng 552,95 KB

Nội dung

Chapter 8: Reorganize Index Task 121 After the Reorganize Task runs, it produces a text report similar to the following: Microsoft(R) Server Maintenance Utility (Unicode) Version 10.0.2531 Report was generated on "HAWAII." Maintenance Plan: MaintenancePlan Duration: 00:00:15 Status: Succeeded. Details: Reorganize Index (HAWAII) Reorganize index on Local server connection Databases: AdventureWorks Object: Tables and views Compact large objects Task start: 2009-07-30T15:05:51. Task end: 2009-07-30T15:06:06. Success Command:USE [AdventureWorks] GO ALTER INDEX [PK_AWBuildVersion_SystemInformationID] ON [dbo]. [AWBuildVersion] REORGANIZE WITH ( LOB_COMPACTION = ON ) GO USE [AdventureWorks] GO ALTER INDEX [PK_DatabaseLog_DatabaseLogID] ON [dbo].[DatabaseLog] REORGANIZE WITH ( LOB_COMPACTION = ON ) GO While the above is an abbreviated report, yours will show the ALTER INDEX command run for every index in every table in your selected databases. If there are any problems or error messages, you will see them here also. Reorganize Versus Rebuild Now that you have a little background about Rebuild and Reorganize, I think it's time for a more comprehensive summary of the pros and cons of using the Reorganize Index task versus using the Rebuild Index task. With this information, you will be better able to make an educated decision on which option is right for your particular circumstances. Chapter 8: Reorganize Index Task 122 Reorganize Index Task Rebuild Index Task Removing empty space and logical fragmentation Performs a less thorough index defragmentation than Rebuild Index. If an index does not have any fragmentation, then it is not reorganized, saving resources. Virtually all wasted free space and logical fragmentation is removed. All indexes are rebuilt from scratch, whether they need it or not. Performance impact Does not require long blocking locks. An online task that allows users to access the database during the task. Requires potentially long blocking locks that prevent users from accessing the indexes being rebuilt. A task that should be performed oine, though with the Enter- prise Edition of SQL Server, you can use the online version of rebuilding an index. Speed Generally takes longer to run than the Rebuild Index Task. Generally runs faster than the Reorganize Index Task. Space requirements Uses less disk space than the Rebuild Index Task. Uses less space in the transaction log than the Rebuild Index Task. Uses more disk space than the Reorganize Index Task. More space is required in the transaction log than the Reorgan- ize Index task. Statistics maintenance Index and column statistics must be updated separately. This adds to the administration hassle. Index and column statistics are automatically updated as part of this step, using the FULLSCAN option. Chapter 8: Reorganize Index Task 123 When and How Often to Reorganize Indexes As I stated in the previous chapter, my general preference is to use the Rebuild Index task, as long as it fits into my available maintenance window. If I don't have an available maintenance window, then I generally use the Reorganize Index task, along with the Update Statistics task. So, before you choose Reorganize over Rebuild, or vice versa, you need to determine what your maintenance windows are. While the Reorganize Index task does offer you the option to run the task outside maintenance windows, I would still advise against this if possible. Although the performance impact of this task, along with Update Statistics, will be much lower than for the Rebuild Index task, it could still be felt by the users, especially if your database tables are large and your servers busy. As such, if you've chosen the Reorganize Index task, here are my general scheduling recommendations, when using the Maintenance Plan Wizard. • Nightly, if possible. If running both the Reorganize Index task and Update Statistics task does not significantly affect users, I suggest you run these two tasks daily, picking a time when running them will have the least impact. • Consider alternatives, otherwise. If running the Reorganize Index task and Update Statistics task does affect user performance, then you may need to consider exerting a finer-grained control over the process, using T-SQL or PowerShell scripts. Configuring the Reorganize Index Task Now that we have a basic understanding of when you might use the Reorganize Index Task, let's take a look at how to configure it, using the Maintenance Plan Wizard. The Define Reorganize Index Task screen is similar to the Define Rebuild Index Task screen, but it has fewer options, as shown in Figure 8.1. Chapter 8: Reorganize Index Task 124 Figure 8.1: The Reorganize Index Task screen is similar to the Rebuild Index Task, but it has fewer options. Database Selection The options here, with the Databases, Object and Selection drop-down boxes, are the same as those described in the equivalent section of the Rebuild Index chapter (Chapter 7), so I will not walk through them again. As before, my advice is that you select the same database or databases here as for every other task that comprises the plan. There may be some special cases where you need to use one plan for one set of databases, using the Reorganize Index task, and a different plan for other databases, using the Rebuild Index task. However, this does begin to negate one of the big selling points of using the Maintenance Plan Wizard: simplicity. If you need to use both the Reorganize Index task and the Rebuild Index task on the same SQL Server instance, you may be better off creating a manual maintenance plan using T-SQL or PowerShell. Chapter 8: Reorganize Index Task 125 Don't be tempted to configure Rebuild and Reorganize in a single plan While it is possible to create a single Maintenance Plan that will run the Reorganize Index task and the Update Statistics task for some databases, and to run the Rebuild Index task for other databases, this can get confusing very quickly. Instead, create separate Maintenance Plans, as I described previously. As with the Rebuild Index task, you also have the ability to select an individual database, and then narrow the scope of the task to one or more tables or indexed views. Just as I suggested you should not use this feature with the Rebuild Index task, I make the same recommendation here. If you are at the point where you need to pick and choose which tables and indexed views to reorganize, then you would be better off using T-SQL or PowerShell scripts to do this task for you, as the Maintenance Plan Wizard is very inflexible. Compact large objects The only major task-specific option that we need to consider is whether or not to select the Compact large objects option, as shown in Figure 8.2. Figure 8.2: Generally, you will want to keep this option selected. It is checked by default, which means that if a table on which this task runs stores LOB data (text, ntext, or image data types), then LOB data in these tables will be treated just the same as any other type of data, and will be reorganized. If you deselect this option, then LOB data will not be reorganized. Generally, you will want to keep this option selected, as reorganizing LOB data can boost the performance of your database. Of course, if you have a lot of LOB data, then this task will take more time, which is to be expected. If you don't want to take this extra time, or you don't care about LOB data compaction, then you can turn this option off. When you do, the ALTER INDEX command will change to: ALTER INDEX index_name ON table_name REORGANIZE WITH ( LOB_ COMPACTION = OFF ) . a text report similar to the following: Microsoft(R) Server Maintenance Utility (Unicode) Version 10.0.2531 Report was generated on "HAWAII." Maintenance Plan: MaintenancePlan Duration:. the Maintenance Plan Wizard: simplicity. If you need to use both the Reorganize Index task and the Rebuild Index task on the same SQL Server instance, you may be better off creating a manual maintenance. where you need to pick and choose which tables and indexed views to reorganize, then you would be better off using T -SQL or PowerShell scripts to do this task for you, as the Maintenance Plan

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

TỪ KHÓA LIÊN QUAN