dm_db_index_physical_stats to filter on db instead of the where clause ips. This schema modification lock blocks all other concurrent access to the table, but it is only held for a very short period of time while the old index is dropped and the statistics updated. Its wide range of features allows users to create and. That means that if i stop the process and restart it, indexes not fragmented won't need reindex. For the SQL Servers we manage for our clients, we use. What is Fragmentation. Set log file to start at 1 GB. While index reorganization is a pure cleanup. Thanks for the info on Showcontig and Index Defragmentation. You’d have to set this up on your own. Clearing the plan cache causes recompilation of all later execution plans and may cause a sudden, temporary decrease in query performance. In fact, once you start focusing on defragmentation at the SQL Server level – whether with manual defragmentation or with the automated defragmentation provided with SQL Defrag Manager, you may decideDatabase Index Defragmentation Tool for SQL Server. DBREINDEX = rebuild a copy of the index (es) from scratch. However, over time and especially when heavy. Check the comment header block for its documentation. For more details, we could refer to the following articles:I think you need index_id in the joins against sys. Use DBCC INDEXDEFRAG to defragment an index. Index Recommendations and ORDER BY’s. If you have fragmentation, you need to REBUILD or REORGANIZE. Maintenance. dm_db_index_physical_stats in SQL Server 2005 and later. Both are deprecated in favour of ALTER INDEX where. If you need more tempdb space, you can scale up the data warehouse. We need to identify all the indexes that are fragmented and defrag them to achieve better performance. SQL Server Index Maintenance-Conditional Rebuilds. The database will be shrunk leaving it. Create/restore new database from the recently created backup. Optimal. This procedure automatically chooses whether to rebuild or reorganize an index according to its fragmentation level, amongst other parameters, and update. It is designed specifically to overcome the compromises DBAs have to make regarding the important task of index fragmentation maintenance. SELECT ips. DBCC SHRINKFILE does what the name implies. 0 supports the SQL statements and syntax described in this chapter. After the index rebuilds, query was way faster when comparing to clean buffer caches. logical fragmentation is just mismatch between Logical ordering of Index keys and physical. It appears to be a bug in 2012 R2. A SQL Server DBA myth a day: (29/30) fixing heap fragmentation. If it grows often, it could concievably become fragmented. There is all reason to only rebuild index that are fragmented, and a good maintenance. Apart from disk space you should not be too worried. Enter a Name and Description for the agent job, and then select OK. This white paper compares two of those statements: DBCC DBREINDEX and DBCC INDEXDEFRAG. This article serves as a guide as to how to automate and schedule SQL Server index defragmentation, and covers three different ways of doing it. [index_id] = [idx]. Paul Randal. The general consensus is if fragmentation is: Less than 10% – there is no need to do anything to the index. The datafile. This tool provides index analysis to manage index defragmentation, including rebuild and reorganize fragmented indexes . Index fragments occur when any transaction takes place in database table. There are two main ways to defragment a Heap Table: Create a Clustered Index and then drop it. Math. This new DMF ( sys. With ApexSQL Defrag you can rebuild or reorganize fragmented indexes in real time, as well as create policies and apply them to multiple databases or servers. Why do you think defragging is an operation eligible for minimal logging? I don. [object_id]) as [TableName] ,SI. I would highly recommend using a tool specific to sql server to defragment the drive(s) on which the files sit. ) Then rerun the above free-space query again to see how the shrink worked: Free space after. If you have a clustered index on the table the fastest way to defragmanet your table would be to drop and recreate the clustered index. There are three options to remove fragmentation in heaps: Create a clustered index and drop it once it is completed. The fill factor determines the amount of empty space on each page in the index, to accommodate future expansion. 4 Answers. Microsoft best practice says that you should generally not do a rebuild operation unless fragmentation is over 30%. There's a general consensus that you should reorganize ("defragment") your indices as soon as index fragmentation reaches more than 5 (sometimes 10%), and you should rebuild them completely when it goes beyond 30% (at least that's the numbers I've heard advocated in a lot of places). Maintenance. Fragmentation may become significant in tables with more than 1000 pages in them. Starting with SQL Server 2005 the recommended way (required starting in SQL Server Kilimanjaro) to defragment indexes is by using the ALTER INDEX statement with the. This puts unnecessary pressure on the buffer pool and. SQL Server then swaps these pages in a discrete transaction. Review ALTER INDEX command on MSDN. Below is a simple query that will provide a list of indexes, fragmentation percentage, and record counts for each table in a database. It has its own disk space and is arranged in a B-tree structure. This can be checked using:. Daily – 6% fragmented. We would like to show you a description here but the site won’t allow us. Defragmentation in Practice. Perform logical consistency checks on indexes. It makes your indexes larger and many operations slower by making the SQL Server access more pages than necessary. [index_id] The name of the index. It is compatible with all versions of SQL Server 2005 , 2008 , 2012 , 2014 and 2016. Defrag indexes on very large production tables. Maintenance. Your best assistant here is our SQL Defrag feature, seamlessly integrated with dbForge Studio for SQL Server . Michelle Ufford (a. Product', PK_Product_ProductID); GO. This mechanism allows defragmenting required indexes on a regular basis since index fragmentation takes place constantly in the 24/7 system. Sorted by: 2. DBCC IndexDefrag – 1015984 ms (1,016 secs or just under 17 minutes to complete) Alter Index ReOrganize – 345512 ms (346 secs or just under 6 minutes to complete) DBCC DBReIndex just like mentioned at the start of this blog is being deprecated. There are two types of fragmentation: Internal Fragmentation and External Fragmentation. Identify Skewed and Outdated Index and Column Statistics and Ensure they are Representative and Up-to-DateAs stated though you would need to shutdown SQL Server, or at least take the DB offline to do an OS Defrag. dm_ db_ index_ physical_ stats (in 2005+). This script has been tested and will work with SQL Server 2005, SQL Server 2008, SQL Server 2008R2, SQL Server 2012, SQL Server 2014, SQL Server 2016, SQL Server 2017 and SQL Server 2019. SQL Server does not maintain when an Index was last rebuild, instead it keeps information when stats were last updated. Receive email notifications for policy and. On version 2019 it runs for over 30 minutes. The link points to SQL Server 2014 docs, but the syntax should work on 2005 and 2008 as well. In this article, I will provide a mechanism for automating SQL Server index defragmentation implemented in a database used in the company I work for. Index automation Job script. INSERT INTO [dbo]. So let’s take one thing at a time. dm_db_index_physical_stats in SQL Server 2005 and later. dm_db_index_physical_stats(DB_ID(N'XXXMYDATABASEXXX'),. SQL SERVER – Sharpen Your Basic SQL Server Skills – Learn the distinctions between unique constraint and primary key constraint and the easiest way to get random rows from a table Next Post SQL SERVER – Simple Example of Cursor – Sample Cursor Part 2 This causes a lot of free space or, as you call it, fragmentation. VLF Fragmentation inside of SQL Log files. To check for index fragmentation using SSMS, open Object Explorer and navigate to the index you want to check. On the right panel, right-click SQL Server Agent. [name] , ips. If not specified, all non-system databases plus msdb and model will be defragmented. Even though it should be safe, I would not want to defrag disks in Production while SQL is running. indexes. 1. Contact the manufacturer of the defragmentation tool to learn how files are locked and how this could affect SQL Server concurrency. dm_db_index_physical_stats system function. Enter a Name and Description for the agent job, and then select OK. This REBUILD option is available in SQL Server 2008 onwards. Rob Sheldon tackles the subject of Index Defragmentation in SQL Server 2005 and 2008, using the sys. The first method is the Fragmentation page of the SQL Server Index Properties window. Yes, rebuilding indexes will take a toll on your transaction log file. In this article. All the Clustered indexes were fixed. Create a clustered index and move it away from the heap. Set the lower limit, as a percentage, for medium fragmentation. After running your script in SQL 2005 I still don’t see any index defrag changes not with a 3-rd party monitoring tool or by running this: USE master SELECT * FROM. 1. To create a new maintenance plan, right click on Maintenance Plan and select New Maintenance Plan and the following window will open. From this tab, select a SQL Server instance in the server explorer on the left and choose database (s) as a target of index operation. For example, you can use ApexSQL Defrag to review the index usage statistics and apply the suitable. You should always do some form of intelligent rebuilding - i. (SQL Server) How to defragment indexes with LOBs? 1. This means every time we need to scan the index, it’ll take 10%. In older versions of SQL Sentry, this feature is disabled by default. It is designed. A disk defragmenter moves all files, including the database file, into contiguous clusters on a hard disk. No, there is no auto-magical defragging of indexes. @dbScope specifies a database name to defrag. The method (not a trick), therefore, is to Create Clustered Index only for the purpose of de-fragmenting the Heap, and drop it afterward. You have the option LOB_COMPACTION. The defragmentation of a heavily fragmented index can generate more log than a fully logged index creation. Defrag indexes on very large production tables. SQL will order its data file, but that is still subject to the OS's allocation of physical space for that file. This article explains how to create customized policies for index defragmentation jobs for SQL Server Introduction When creating indexes, database administrators should look for the best settings to ensure minimal performance impact and degradation. After the defragmentation, the following is the fragmentation report of our db. If you're looking for whenif the index was ever rebuilt, the Ola sp does have the ability to log to a table and the previous DBA hopefully utilized this feature. ApexSQL Defrag is a powerful application used for scheduled analyzing and defragmenting of SQL Server database indexes. As of version 2020. Here are some steps you can follow to free up some space in a hurry. Refer to the below links:The downside to using the Reorganize Index task is that its index defragmentation capability is not as thorough and complete as the Rebuild Index task. 2. SQL Server 2005 and later provides a dynamic management function (DMF) to determine index fragmentation level. Online vs offline SQL Server index rebuild in SQL Server. Defragment on-demand and via schedules. dm_db_index_physical_stats function is the preferred tool to use to check index fragmentation on any CA or DA database table. Review Using SQL Server DMVs to Identify Missing Indexes tip. REBUILD WITH (ONLINE=ON) some of them still remain fragmented. Also need to defragment the tables, since the allocations within. For a heap, the associated PFS and IAM pages are examined and the data pages of a heap are scanned in LIMITED mode. It's a. It automates the time-consuming process of finding fragmented indexes based on policies for the targeted databases. Contig can defragment SQL Server database and log files while the databases are online, but there is some performance cost (whether or not the. Index names must follow the rules of identifiers. INDEX DEFRAG on SQL SERVER 2005. The best recommendation I have is to create your own procedure which loops through the tables of the database and runs DBCC INDEXDEFRAG. Share. Note that the time limit is checked BEFORE an index defrag begins, thus a long index defrag can exceed the time limit. But it is not recommended. This article shows an example of how to manually perform defragmentation on an index using SQL Management Studio. Yup. Rebuild if > 30%. MS SQL Server always updates index statistics whenever an Insertion, Updating, or Deletion activity is performed on the . * The nonclustered index is fairly wide, with lots of columns * The clustered index is relatively narrow (doesn’t have many more fields than the nonclustered, especially big varchar fields) * The nonclustered index has extremely bad internal fragmentation * The clustered index has nearly no fragmentation (quite an interesting combination)Mar 8, 2021, 2:47 PM. 3. Expand the Tables folder. Index Defragmentation is one of the key processes to significantly improve performance of any database. This job needs to be scheduled and ran on a weekly basis due to. February 6, 2019. */Effective database performance tuning often relies on having precise database insights to determine actual root causes. One solution is to deploy a faster I/O subsystem, where page splits would be less of an issue. Reports index length stats for indexes who's lengths exceeding parametrized thresholds (defaults to 0 - get all) for total length and seek length. Yes it will - but only to a certain degree. In order to test this scenario, we could use the other table we created earlier - Product_B. Leverage solutions such as Adaptive Index Defrag to automatically manage index defragmentation and statistics updates for one or more databases. You also can create a linked server to SQLAZURE and create a sql agent job. Next Steps This is a simple base script that could be modified into a stored procedure and also allow you to pass other parameters such as doing an index. [name] as 'Schema', dbtables. It has been proven that Online Index Rebuild – Can Cause Increased Fragmentation when it is allowed to run with MAX DOP > 1 and ALLOW_PAGE_LOCKS = OFF directives. Note that the time limit is checked BEFORE an index defrag begins, thus a long index defrag can exceed the time limit. You can use Ola's Index maintenance solution or Michelle Ufford's - Index Defrag Script. Fragmentation typically happens owing to insert, update and delete transactions. If only table_id is specified or if index_id is 0, the data pages of the specified table are scanned. Go to DBACOCKPIT –> Performance –> SQL Statements. k. The DBCC Defrags will put the data in better order. The following query ran for ten minutes on version 2008. OBJECT_ID) AS TableName, fq. SQL Defrag Manager offers a totally new way to identify, optimize, manage and automate SQL Server defragmentation. Veritas now uses the heavily debated command DBCC SHOWCONTIG WITH ALL_INDEXES,or DBCC SHOWCONTIG WITH ALL_INDEXES,tableresults (Table results will give you a table format to read) to monitor the health of the table indexes when the use of the sys. A starting point could be looking at the queries being executed on your server. Rebuild drops and recreates the index. 2027. Just ignore the small indexes, fragmentation is irrelevant for those anyhow. Weekly – 3% fragmented. Remarks. But only if the index is bigger than a small-thing (I forget exactly, but some really small tables appeared frag'd immediatly after reindex), and is more than 20% fragmentated. These pages can get empty space on them and become out of order over time as well. For more information, see sys. Only files marked by the system as "not moveable" can't be defragmented. Use the ALTER TABLE command to rebuild the Heap. Reorganize or rebuild an index SQL Server Management Studio. Receive email notifications for policy and. avg_fragmentation_in_percent as Fragmentation, indexstats. FragmentationLevel1. Or with other fill factors I tested: - Setting a Fill factor of 80 on the clustered index (Fragmentation > 98%. Right click the index, click Properties, then click Fragmentation to see the fragmentation and page fullness percentages. avg_fragmentation_in_percent, ips. SQL Server will by default perform a NOTRUNCATE which will move data pages from the end of the file to any free space at the beginning of the database data file. Your primary concern is getting your SQL Server back online. Aug 26, 2015 at 15:42. Prioritize defragmentation by fragmentation level, scan density, and index size. The only way to get rid of this fragmentation is to rebuild both the non-clustered index and the clustered index. page_count, ips. The Ultimate Index Width Stats Reporter. Any indexes above 50% in fragmentation percentages that affect more than 4000 rows are bad, and the system performance can significantly benefit from defragmenting the indexes. SQL SERVER – 2005 – A Simple Way To Defragment All Indexes In A Database That Is Fragmented Above A Declared Threshold. Lock durations are short and will cause minimal blocking of queries. So we defragment and build indexes twice a week. Not so much if the file is spread out all over the disk. 00 am - Index defrag' : Step 1, 'run index defrag' : Began Executing 2012-06-27 02:00:05 DBCC: Defrag phase of index 'table1_pk_index' is 27% complete. Indexing. Maintenance tasks on a database, index, or filegroup. For this example, the defragmentation reduces the size of the index by more than 3x (from 25 pages to 7 pages) and the table consumes just over 50% less space. ; usp_AdaptiveIndexDefrag_PurgeLogs, which will purge the log tables of data older than 90 days, to avoid indefinite growth. Microsoft Certified Master: SQL Server, MVP, M. It's not free, so if you're. Often, this is not enough to perform index. Here is a. SELECT OBJECT_NAME (fq. Delete the other 7 files. To work around a very large index that won't defragment, the BEST solution is to pre-size a new database and move all your objects to that DB. You can find the same info here for newer. Collection of solution center articles on SQL index defragmentation topic. The name of the index. When auto-index defragmentation is enabled in Orion, databasemaintinence will sometimes fail to defragment highly fragmented indexes will get defragmented during the Orion database maintenance, which runs at 2:15 AM by. Reorganize index and level of defragmentation. Lock durations are short and will cause minimal blocking of queries. You can also change this threshold via parameters. The operation only requires an intent-shared (IS) table lock. I want to defrag tables in sql server, I used this code to know the fragmented indexes: sELECT dbschemas. dm_db_index_physical_stats to get information about your index fragmentation (see the avg_fragmentation_in_percent column). Otherwise, nothing special. Daily – 6% fragmented. Over time, the indexes created for an SQL Server database can become fragmented. The syntax is: "java. That article is in-depth and difficult to summarise in this reply, but it comes down to creating an asynchronous. DBCC INDEXDEFRAG can defragment clustered and nonclustered indexes on tables and views. In enterpise edition of SQL server you can also rebuild index online (which is better than index defrag for performance) Yes. Script to Manage SQL Server Rebuilds and Reorganize for Index Fragmentation. Select * from sys. Compression enabled on both. This procedure automatically chooses. Sorted by: 1. You can't do online index rebuilds. The reason why too many page splits can decrease the performance of SQL Server is because of the large number of I/O operations. The SQL Server Index and Statistics Maintenance part of Ola Hallengren’s solution consists of IndexOptmize stored procedure and IndexOptimize – USER_DATABASES agent job, that are created during the installation process. If you want to run it on every user database on your server, simply replace DB_ID () with NULL in the call to sys. dm_ db_ index_ physical_ stats (in 2005+). Now SQL have 4 threads to the database and not one. Improve this answer. The above query is database specific. But think it through. The default is 5 percent. SQL Server 2000 introduces a new DBCC INDEXDEFRAG statement to defragment clustered and nonclustered indexes on tables and views. Next Steps This is a simple base script that could be modified into a stored procedure and also allow you to pass other parameters such as. I'd consider doing a LOB_COMPACTION less frequently but both options comes down to your maintenance windows duration pretty much. We defrag if the index is large, otherwise reindex. To create SQL Server agent that will defragment specified indexes automatically, perform the following steps: Expand SQL Server Agent in Object explorer, right click on Jobs, and select New Job…: In General tab, specify the name and description for the job. 2. Monitor tempdb during rebuild operations. SQL Server Index Defragmentation. Defragmenting an Index. Fragmentation >=30 AND PAGES>1000 then. According to the index performance value, users can take the indexes in maintenance by revising the fragmentation percentage with the help of Rebuild or Reorganize operation. In SQL 2005, you can query DMV sys. We have a SQL 2016 database that has a 1. 1. Jul 27, 2021, 8:03 PM. dm_db_index_physical_stats also provides fragmentation information for each partition. With both SQL 2000 and SQL 2005 and later versions you can get the fragmentation information by using the DBCC SHOWCONTIG command. We also checked the indexes of the tables that are accessed sequentially on process overview. Defragmentation utilities may lock sections of the file, preventing SQL Server from completing a read or write operation. The maintenance plan. If you are experiencing slow full-text query performance, you can use sys. July 17, 2012 at 12:16 pm. There is all reason to only rebuild index that are fragmented, and a good maintenance. About; Products. In addition,. In short, defragmentation is essential for performance improvement of SQL. Now, all you have to do is download the T-SQL script, execute it on your Azure SQL DB and execute the maintenance procedure. Creating a SQL Server Maintenance Plan. However, imagine that you have seven years of data. How Defragmentation Improves Performance. Remarks. It automates the time-consuming process of finding fragmented indexes based on policies for the targeted databases. At first glance, that would seem to indicate that your database got worse off if you defragmented! But like all good novels (and most bad ones), the plot thickens. Review SQL Server script to rebuild all indexes for all tables and all databases tip. "Partitioning Clustered Indexes When partitioning a clustered index, the clustering key must contain the partitioning column. It depends on the degree of fragmentation of Indexes. Create a execute sql task and schedule it through sql agent . Name : CoreCount. dm_db_index_physical_stats DMF to. For example, one of the indexes with a page_count of 967 has a fragmentation percentage. Fragmentation causes issues where it takes SQL Server more time to traverse the index tree to find the necessary records. 8. Fragmentation typically happens owing to insert, update and delete transactions. Customize triggers to start and stop defragmentation. When I got the stats from dm_db_index_physical_stats , there were still 27 records which needed defrag and all of theses were NON CLUSTERED Indexes. 0. This puts unnecessary pressure on the buffer pool and also negatively impacts. Reorganize index and level of defragmentation. Reports index length stats for indexes who's lengths exceeding parametrized thresholds (defaults to 0 - get all) for total length and seek length. You're allowed to define online/offline rebuilds, reorganizations, stats updates, partition level operations, etc. Larger indexes have more intermediate levels and pages. This may affect the concurrency of the server that's running SQL Server. According to Microsoft guidelines, based upon index fragmentation percentage, we may choose to either REORGANIZE,. Index fragmentation can cause high CPU usage, which means disk usage, and therefore performance degradation. There are two ways of doing that: (i) by using the ‘ DBCC SHOWCONTIG ‘ command, and (ii) by using the ‘ sys. Share. If you what you are saying is true, even. ALTER DATABASE [Inter3112] SET OFFLINE GO. In the CREATE INDEX to can tell SQL Server to sort in TempDB vs. While you are at it, by all means, use. Reference: Pinal Dave (I had some indexes on a table with around 700m rows that I couldn't defragment below around 30%. Maintenance. is_ms_shipped = 0 --Excludes any objects created as a part of SQL Server installation AND ss. According to Microsoft guidelines, based upon index fragmentation percentage, we may choose to either REORGANIZE, REBUILD indexes or just ignore. DO: Implement appropriate index fill factors. Expand the table on which you want to reorganize an index. We have a database with 2 tables, one with hundreds of millions of rows (row size<1KB), another 14 million rows. Review CREATE INDEX. A proper query analysis plan has to be built and followed. 2005, but if you read around the 'net you'll find many more references to choose to rebuild your indexes via the ALTER INDEX command, which is new for SQL Server 2005. The sys. DBCC DBReIndex – 356610 ms (357 secs or just under 6 minutes to complete). The first time you enable it, the Fragmentation ManagerWizard displays. Some people recommend not defragmenting tables under 1000 pages. SP_BlitzCache can help with finding your worst performing queries. Check the comment header block for its documentation. I'd rebuild stats every night at least. This REBUILD option is available in SQL Server 2008 onwards. There are two types of fragmentation: Internal Fragmentation and External Fragmentation. mdf file size: your disk have to have space to re-allocate a 35-gig file, in order to defragment it. It is probably better to use the first parameter of sys. #1637994. Then, choose New, Job to create a SQL agent job. ApexSQL Defrag tool is a 3 rd party SQL index defragmentation tool that you can easily use to perform number of operations related to the SQL Server indexes. You can use sys. Microsoft best practice says that you should generally not do a rebuild operation unless fragmentation is over 30%. Select Steps, and then select New to add an execution step. SQL Defrag Manager is a unique solution for defragmenting indexes for SQL Server. . Example: Name: Indexrebuild_job; Description: RDS for SQL server agent job for index rebuild. 25. This point here is extremely important. This tool provides index analysis to manage index defragmentation, including rebuild and reorganize fragmented indexes . Let the internal health rule which takes care of index fragmentation run. NAME + '] ON [' + Object_name(ind. Leverage solutions such as Adaptive Index Defrag to automatically manage index defragmentation and statistics updates for one or more databases. When you purge the table, you need to rebuild the index(s) on the table which will defrag the table data. The method (not a trick), therefore, is to Create Clustered Index only for the purpose of de-fragmenting the Heap, and drop it afterward. Otherwise, nothing special. Failing that (ie Standard Edition etc), look at re-organizing indexes - these will keep them online. If it does not, the table is considered a HEAP. Review resource utilization before defragmentation to avoid contention. @tblName specifies if you only want to defrag indexes for a specific table. 0. Compression enabled on both. Fortunately, like Windows 7, Server 2008 can on a schedule defrag. The answer to this is simple, Shrinking causes Logical fragmentation. Example: Name: Indexrebuild_job; Description: RDS for SQL server agent job for index rebuild. Defragment Indexes. set @current_sql = (select top 1 Reorganize_SQL from @fragmented_indexes) execute sp_executesql @current_sql--select. Fragmentation causes issues where it takes SQL Server more time to traverse the index tree to find the necessary records. Here I use 4 conditions : 1. Expand the Tables folder. SQL Server. Proceed to the Steps tab: Clicking on New. We have a Non-Clustered index on the varbinary field and our index maintenance scripts perform a REORGANIZE on this every 2-3 days. The indexes are left as they were at the time of backup. 2. 2. avg_page_space_used_in_percent, ips. Maintaining indexes is an ongoing and very responsible job assignment. You’d have to set this up on your own. The "index optimize" job created by Ola's install script focuses on defragmentation, not statistics update. Yes, this is due to low page count. 16 years ago. SQL Defrag Manager offers a totally new way to identify, optimize, manage and automate SQL Server defragmentation. [index_id] , idx. dm_db_index_physical_stats (Transact-SQL). Reorganize/Rebuild SQL Server database indexes using ApexSQL Defrag ApexSQL Defrag is a 3rd party tool made specifically to automatically fix index fragmentation in SQL Server databases. Sql server 2005 needs daily index defrag. SQL Defrag Manager is a unique solution for defragmenting indexes for SQL Server.