<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4197314054054678728</id><updated>2011-11-27T16:24:02.240-08:00</updated><category term='indexes'/><category term='CXPACKET'/><category term='wait types'/><category term='performance'/><title type='text'>SQL-Search</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sqlsearch.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4197314054054678728/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://sqlsearch.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ajay Varma</name><uri>http://www.blogger.com/profile/14835085313182660954</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4197314054054678728.post-2488154117892108245</id><published>2008-12-25T20:57:00.000-08:00</published><updated>2008-12-25T20:58:19.425-08:00</updated><title type='text'>Move indexes to Other Filegroup in SQL server 2005.</title><content type='html'>I have seen many peoples having trouble with moving indexes to different file group.There is no such available feature to move all non-clustered indexes to other file gruop for better performance and handel disk threshold.&lt;br /&gt;&lt;br /&gt;You can have this procedure executed on production to move indexes to another filegroup.&lt;br /&gt;&lt;br /&gt;ALTER PROC uspMoveTableToFileGroup &lt;br /&gt;@TblName VARCHAR(200),&lt;br /&gt;@tblFileGroupName VARCHAR(200),&lt;br /&gt;@indFileGroupName VARCHAR(200) AS&lt;br /&gt;&lt;br /&gt;SET NOCOUNT ON&lt;br /&gt;create table #indx (index_name VARCHAR(200), index_description VARCHAR(200), index_keys VARCHAR(200))&lt;br /&gt;&lt;br /&gt;INSERT #indx (index_name , index_description , index_keys) EXEC sp_helpindex @TblName&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;--SELECT 'SELECT ' + '''' + 'Table :' + @TblName + ''''&lt;br /&gt;--SELECT 'SELECT ' + '''' + 'Start Time : ' + '''' + ' + CONVERT(char(25), GETDATE(), 121)' +&lt;br /&gt;--    CHAR(13) + ' GO '&lt;br /&gt;--SELECT 'DECLARE @StartDt DATETIME'&lt;br /&gt;--SELECT 'SET @StartDt = GETDATE()'&lt;br /&gt;&lt;br /&gt;SELECT 'CREATE ' + &lt;br /&gt;  CASE WHEN CHARINDEX('UNIQUE', index_description, 0) &gt; 0 THEN 'UNIQUE ' ELSE '' END +&lt;br /&gt;  CASE WHEN SUBSTRING(index_description,1,3) = 'non' THEN 'NONCLUSTERED ' ELSE 'CLUSTERED ' END + &lt;br /&gt;  ' INDEX ' +&lt;br /&gt;  index_name + CHAR(13) + ' ON ' + 'dbo.[' + @TblName + ']' + &lt;br /&gt;  '(' + replace(index_keys, '(-)', ' DESC') + ')' + ' WITH DROP_EXISTING ON ' &lt;br /&gt;  + '[' + CASE WHEN SUBSTRING(index_description,1,3) = 'non' THEN @indFileGroupName ELSE @tblFileGroupName END + ']'&lt;br /&gt;FROM #indx&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;--SELECT 'SELECT ' + '''' + @TblName + ', ' + '''' + ' + CONVERT(char(25), @StartDt, 121)' + '+' +&lt;br /&gt;-- '''' + ', ' + '''' +&lt;br /&gt;-- ' + CONVERT(char(25), GETDATE(), 121) ' + '+' + '''' + ', ' + '''' + '+' +&lt;br /&gt;-- ' CAST(DATEDIFF(ss, @StartDt, GETDATE()) AS VARCHAR(20))' + CHAR(13) + ' GO '&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;select 'exec uspMoveTableToFileGroup ' + &lt;br /&gt;  '''' +  name + '''' + ', ' +&lt;br /&gt;  '''' + 'Primary' + '''' + ', ' +&lt;br /&gt;  '''' + 'INDEX_FG' + ''''&lt;br /&gt;from sysobjects&lt;br /&gt;where xtype = 'U'&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Thanks&lt;br /&gt;Ajay&lt;br /&gt;Sr. SQL DBA&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4197314054054678728-2488154117892108245?l=sqlsearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlsearch.blogspot.com/feeds/2488154117892108245/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4197314054054678728&amp;postID=2488154117892108245' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4197314054054678728/posts/default/2488154117892108245'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4197314054054678728/posts/default/2488154117892108245'/><link rel='alternate' type='text/html' href='http://sqlsearch.blogspot.com/2008/12/move-indexes-to-other-filegroup-in-sql.html' title='Move indexes to Other Filegroup in SQL server 2005.'/><author><name>Ajay Varma</name><uri>http://www.blogger.com/profile/14835085313182660954</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4197314054054678728.post-6789961156572595047</id><published>2008-12-24T02:47:00.000-08:00</published><updated>2008-12-24T02:55:45.710-08:00</updated><title type='text'>Setting Up Mirroring and Log Shipping Together.</title><content type='html'>Setting Up Mirroring and Log Shipping Together.&lt;br /&gt;&lt;br /&gt;Prerequisite (Sql Server 2005)&lt;br /&gt;•Server A ( Principal)&lt;br /&gt;•Server B (Mirror)&lt;br /&gt;•Server C ( Secondary Standby) for Logshipping&lt;br /&gt;•Share Folder on Network, Accessible by all three Servers (A, B &amp; C).&lt;br /&gt;&lt;br /&gt;1.Restore backups of the principal/primary database with NORECOVERY onto another server instance to be later used as database mirroring mirror database for the principal/primary database.&lt;br /&gt;&lt;br /&gt;2.Set up database mirroring. &lt;br /&gt;E.g. Configuring Mirroring on Principal Server.&lt;br /&gt;Server A: Mir (Principal , Synchronized)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_AYHpzxNM4Hc/SVIUVdxTRPI/AAAAAAAAADY/m_KpUbuH1Bs/s1600-h/Mirr_status1.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 200px; height: 24px;" src="http://1.bp.blogspot.com/_AYHpzxNM4Hc/SVIUVdxTRPI/AAAAAAAAADY/m_KpUbuH1Bs/s200/Mirr_status1.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5283307671860233458" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Server B: Mir (Mirror , Synchronized/Restoring)&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_AYHpzxNM4Hc/SVIUoHqPm9I/AAAAAAAAADg/hArUx-ybE8M/s1600-h/Mirr_status2.JPG"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 200px; height: 27px;" src="http://4.bp.blogspot.com/_AYHpzxNM4Hc/SVIUoHqPm9I/AAAAAAAAADg/hArUx-ybE8M/s200/Mirr_status2.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5283307992342567890" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3.Restore backups of the principal/primary database to other Destination server instances to be used as log shipping.&lt;br /&gt;&lt;br /&gt;E.g Restore Backup of Mir database from Server A to Server C with NoRecovery.&lt;br /&gt;&lt;br /&gt;4.Create a Network share Folder to take Tlog backup for both Server A (Principal Databases) and Server B(Mirrored Database)  &lt;br /&gt;E.g. \\192.168.1.15\Backup   -- This Share folder will be used\accessible by Server A, Server B and Server C.&lt;br /&gt;&lt;br /&gt;5.Create a Network Share Folder for Copying Tlog from source to destination. &lt;br /&gt;E.g. \\192.168.1.15\Dest_Backup -- Destination Share Folder from where restore of Log will be done to Server C.&lt;br /&gt;&lt;br /&gt;6.Set up log shipping on the principal database from Server A to Server C according to Schedule backup, restore and latency required.( Use Sql 2005 Management Studio) check Restore Tab option for Standby\ No recovery.&lt;br /&gt;Server C: Mir (Standby/Read only)&lt;br /&gt;   &lt;br /&gt;7.Disable Following job &lt;br /&gt;     1. Disable Logshipping Backup job on server A.&lt;br /&gt;     2. Disable Logshipping Copy Job on server C.&lt;br /&gt;     3. Disable Logshipping Restore Job on server C.&lt;br /&gt;&lt;br /&gt;8.Set up log shipping on the mirror as the inactive primary database. Follow below steps.&lt;br /&gt;  a.Failover Database Mirroring to Server B.&lt;br /&gt;  b.Use same shared folder for Backup and Destination e.g. as used above&lt;br /&gt;    \\192.168.1.15\Backup   &lt;br /&gt;    \\192.168.1.15\Dest_Backup&lt;br /&gt;  c.Set up log shipping similar to done in step 6 from Server B to Server C.&lt;br /&gt;&lt;br /&gt;9.Failover Mirroring to Server A.&lt;br /&gt;&lt;br /&gt;10.Enable all job disable in Step 7.&lt;br /&gt;   1.Enable Logshipping Backup job on server A.&lt;br /&gt;   2.Enable Logshipping Copy Job on server C.&lt;br /&gt;   3.Enable Logshipping Restore Job on server C.&lt;br /&gt;Check logshipping Job are running sucessfully as schedule.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4197314054054678728-6789961156572595047?l=sqlsearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlsearch.blogspot.com/feeds/6789961156572595047/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4197314054054678728&amp;postID=6789961156572595047' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4197314054054678728/posts/default/6789961156572595047'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4197314054054678728/posts/default/6789961156572595047'/><link rel='alternate' type='text/html' href='http://sqlsearch.blogspot.com/2008/12/setting-up-mirroring-and-log-shipping.html' title='Setting Up Mirroring and Log Shipping Together.'/><author><name>Ajay Varma</name><uri>http://www.blogger.com/profile/14835085313182660954</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_AYHpzxNM4Hc/SVIUVdxTRPI/AAAAAAAAADY/m_KpUbuH1Bs/s72-c/Mirr_status1.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4197314054054678728.post-6460495329490933234</id><published>2008-12-10T22:46:00.000-08:00</published><updated>2008-12-10T22:48:45.867-08:00</updated><title type='text'>Replication involved in SQl 2000 and SQl 2005</title><content type='html'>Replication involved in SQl 2000 and SQl 2005 &lt;br /&gt;Publication: database in SQL 2000&lt;br /&gt;Subscriber: database in SQL 2005&lt;br /&gt;&lt;br /&gt;Case: Need to drop article from existing publication.&lt;br /&gt;&lt;br /&gt;Ex: To drop article “Employees” from publication ‘ReplTest’ which is in sql server 2000 publication and database 'ReplTest' &lt;br /&gt;&lt;br /&gt;Connect Publication server and you might follow below steps as in sql 2000 removing article from GUI doesn’t give you option to tick off the article and remove it from publication.&lt;br /&gt;&lt;br /&gt;Use 'ReplTest'&lt;br /&gt;GO&lt;br /&gt;sp_droparticle ‘ReplTest’, 'Employees', &lt;br /&gt;&lt;br /&gt;Server: Msg 14046, Level 16, State 1, Procedure sp_droparticle, Line 161&lt;br /&gt;&lt;br /&gt;Could not drop article. A subscription exists on it.&lt;br /&gt;&lt;br /&gt;Above error say’s if you want to drop article from publication then you need to first drop the subscription and then remove article from publication.&lt;br /&gt;&lt;br /&gt;And dropping subscription and re- adding the same would require you to run fresh snapshot ,This might be huge pain to customer if snapshot size is very large say 150 GB Appox(6 hours). And then again initial synchronization may take (6 hours).&lt;br /&gt;&lt;br /&gt;Total 12 hours maintenance.&lt;br /&gt;&lt;br /&gt;Here what I found something interesting and would like to share. &lt;br /&gt;&lt;br /&gt;If you want to remove article from publication involved with sql 2005 subscription.&lt;br /&gt;&lt;br /&gt;Open SQL 2005 SSMS and connect publication SQL 2000 Server and follow below steps&lt;br /&gt;&lt;br /&gt;·Right click publication properties àarticle and remove the article. (Here it allows us to remove article from same publication not allowed from Enterprise or Sql 2000 QA)&lt;br /&gt;&lt;br /&gt;You might get below screen &lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_AYHpzxNM4Hc/SUC3m4-dewI/AAAAAAAAADE/uvAK838uE6k/s1600-h/Replication_d.jpg"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 200px; height: 154px;" src="http://3.bp.blogspot.com/_AYHpzxNM4Hc/SUC3m4-dewI/AAAAAAAAADE/uvAK838uE6k/s200/Replication_d.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5278420642035497730" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The screen above show subscription needs to be reinitialize but when you run the snapshot it would not generate new snapshot which is good , something foolish error from Microsoft saying subscription be reinitialized from new snapshot.&lt;br /&gt;Thus if you don’t want the whole snapshot to be run as per above scenario, always drop article from SQl 2005 SSMS the same way shown above.&lt;br /&gt;&lt;br /&gt;Also if you need to add article just add the same way as you remove from publication and run the snapshot it would run for only one/ number. of added articles.&lt;br /&gt;&lt;br /&gt;Please revert and let me know if this article helps you or you have any query.&lt;br /&gt;&lt;br /&gt;Thanks,&lt;br /&gt;Ajay Varma,MCTS&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4197314054054678728-6460495329490933234?l=sqlsearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlsearch.blogspot.com/feeds/6460495329490933234/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4197314054054678728&amp;postID=6460495329490933234' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4197314054054678728/posts/default/6460495329490933234'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4197314054054678728/posts/default/6460495329490933234'/><link rel='alternate' type='text/html' href='http://sqlsearch.blogspot.com/2008/12/replication-involved-in-sql-2000-and.html' title='Replication involved in SQl 2000 and SQl 2005'/><author><name>Ajay Varma</name><uri>http://www.blogger.com/profile/14835085313182660954</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_AYHpzxNM4Hc/SUC3m4-dewI/AAAAAAAAADE/uvAK838uE6k/s72-c/Replication_d.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4197314054054678728.post-122127063101430259</id><published>2008-12-10T08:26:00.000-08:00</published><updated>2008-12-10T08:34:31.684-08:00</updated><title type='text'>How Snapshot Isolation and Row Versioning Work</title><content type='html'>How Snapshot Isolation and Row Versioning Work&lt;br /&gt;When the SNAPSHOT isolation level is enabled, each time a row is updated, the SQL Server Database Engine stores a copy of the original row in tempdb, and adds a transaction sequence number to the row. The following is the sequence of events that occurs:&lt;br /&gt;&lt;br /&gt;A new transaction is initiated, and it is assigned a transaction sequence number.&lt;br /&gt;&lt;br /&gt;The Database Engine reads a row within the transaction and retrieves the row version from tempdb whose sequence number is closest to, and lower than, the transaction sequence number.&lt;br /&gt;&lt;br /&gt;The Database Engine checks to see if the transaction sequence number is not in the list of transaction sequence numbers of the uncommitted transactions active when the snapshot transaction started.&lt;br /&gt;&lt;br /&gt;The transaction reads the version of the row from tempdb that was current as of the start of the transaction. It will not see new rows inserted after the transaction was started because those sequence number values will be higher than the value of the transaction sequence number. &lt;br /&gt;&lt;br /&gt;The current transaction will see rows that were deleted after the transaction began, because there will be a row version in tempdb with a lower sequence number value.&lt;br /&gt;&lt;br /&gt;The net effect of snapshot isolation is that the transaction sees all of the data as it existed at the start of the transaction, without honoring or placing any locks on the underlying tables. This can result in performance improvements in situations where there is contention.&lt;br /&gt;&lt;br /&gt;A snapshot transaction always uses optimistic concurrency control, withholding any locks that would prevent other transactions from updating rows. If a snapshot transaction attempts to commit an update to a row that was changed after the transaction began, the transaction is rolled back, and an error is raised&lt;br /&gt;&lt;br /&gt;Script to change Isolation Level.&lt;br /&gt;&lt;br /&gt;ALTER DATABASE DB_NAME&lt;br /&gt;    SET READ_COMMITTED_SNAPSHOT ON;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4197314054054678728-122127063101430259?l=sqlsearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlsearch.blogspot.com/feeds/122127063101430259/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4197314054054678728&amp;postID=122127063101430259' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4197314054054678728/posts/default/122127063101430259'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4197314054054678728/posts/default/122127063101430259'/><link rel='alternate' type='text/html' href='http://sqlsearch.blogspot.com/2008/12/how-snapshot-isolation-and-row.html' title='How Snapshot Isolation and Row Versioning Work'/><author><name>Ajay Varma</name><uri>http://www.blogger.com/profile/14835085313182660954</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4197314054054678728.post-2172681545403007231</id><published>2008-12-08T02:01:00.001-08:00</published><updated>2008-12-10T01:26:09.690-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='indexes'/><category scheme='http://www.blogger.com/atom/ns#' term='CXPACKET'/><category scheme='http://www.blogger.com/atom/ns#' term='wait types'/><title type='text'>CXPACKET wait types</title><content type='html'>Are you experiencing CXPACKET wait types? &lt;br /&gt;&lt;br /&gt;There is a performance issue and user facing slowness during running there application,to find out check the wait type occuring in sql server. If you find out CXPACKET waittype utilizing &gt;5 then there might be a SQL Server parallelism problem and you must reduce MAXDOP to 1.&lt;br /&gt;&lt;br /&gt;If your OLTP queries follow best practices and are well indexed, they probably will never generate a parallel plan. This is because they are fast and access a small amount of rows. &lt;br /&gt;&lt;br /&gt;If they are missing indexes or SQL overestimates cardinality, SQL might decide to do scans, sorts, hashes, spools etc. These iterators, among others, can go parallel to reduce execution time at the cost of system resources. These iterators are not bad and they do have their place. It just isn’t on OLTP type of queries most of the time. &lt;br /&gt;&lt;br /&gt;So dropping the MAXDOP on an OLTP system to 1 probably won’t hurt much because most of the time there is an IO bottleneck. &lt;br /&gt;&lt;br /&gt;If the CXPACKET wait types are a symptoms of poor indexing and row count estimation, it won’t help either. Whole books have been written on indexing, query tuning and there is a nice whitepaper on stats best practices to avoid estimation problems so I am not going to go into that. &lt;br /&gt;&lt;br /&gt;Some recommendations on values for CXPACKET waits and when&lt;br /&gt;parallelism is desirable depending if this is an OLTP system on this whitepaper&lt;br /&gt;&lt;br /&gt;SQL Server 2005 Waits and Queues&lt;br /&gt;&lt;a href="http://www.microsoft.com/technet/scriptcenter/scripts/sql/sql2005/waitstats/sql05vb049.mspx"&gt;http://www.microsoft.com/technet/pro...ts_queues.mspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I have found some queries to identify whether the CXPACKET is a symptom or the cause. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;select r.cpu_time , r.logical_reads, r.session_id into #temp&lt;br /&gt;from sys.dm_exec_sessions as s &lt;br /&gt;inner join sys.dm_exec_requests as r &lt;br /&gt;on s.session_id =r.session_id --and s.last_request_start_time=r.start_time&lt;br /&gt;where is_user_process = 1 &lt;br /&gt;&lt;br /&gt;waitfor delay '00:00:01' &lt;br /&gt;&lt;br /&gt;select substring(h.text, &lt;br /&gt;(r.statement_start_offset/2)+1 , &lt;br /&gt;((case r.statement_end_offset when -1 then datalength(h.text) else r.statement_end_offset end - r.statement_start_offset)/2) + 1) as text,&lt;br /&gt;r.cpu_time-t.cpu_time as CPUDiff , &lt;br /&gt;r.logical_reads - t.logical_reads as ReadDiff, &lt;br /&gt;p.query_plan, &lt;br /&gt;r.wait_type, &lt;br /&gt;r.wait_time, &lt;br /&gt;r.last_wait_type, &lt;br /&gt;r.wait_resource, &lt;br /&gt;r.command, &lt;br /&gt;r.database_id, &lt;br /&gt;r.blocking_session_id,&lt;br /&gt;r.granted_query_memory,&lt;br /&gt;r.session_id, r.reads, r.writes, &lt;br /&gt;r.row_count, s.[host_name],&lt;br /&gt;s.program_name, &lt;br /&gt;s.login_name&lt;br /&gt;from sys.dm_exec_sessions as s &lt;br /&gt;inner join sys.dm_exec_requests as r &lt;br /&gt;on s.session_id =r.session_id and s.last_request_start_time=r.start_time&lt;br /&gt;full outer join #temp as t on t.session_id=s.session_id&lt;br /&gt;CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) h&lt;br /&gt;cross apply sys.dm_exec_query_plan(r.plan_handle) porder by 3 desc &lt;br /&gt;&lt;br /&gt;drop table #temp &lt;br /&gt;&lt;br /&gt;You notice that you have several rows with CXPACKET wait types. With this query, you click the xml show plan link and: &lt;br /&gt;1. search the xml for missing indexes. &lt;br /&gt;2. Save as a .sqlplan and reopen in SSMS&lt;br /&gt;3. Compare estimated and actual rows in the iterators on the right side of the plan. Poor estimates may bubble to the left as well.&lt;br /&gt;4. If there are no missing indexes, estimates and actual are fairly close, reducing MAXDOP may help if it is not a huge report or query.&lt;br /&gt;&lt;br /&gt;5. If there are missing index or bad estimations, fix it!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;One thing to note, if you do turn down MAXDOP server-wide, turn in on at the query level(enterprise edition) on your index operation because they are optimized for it.&lt;br /&gt;Alter index all on tblBlah rebuild with (maxdop=32);&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4197314054054678728-2172681545403007231?l=sqlsearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlsearch.blogspot.com/feeds/2172681545403007231/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4197314054054678728&amp;postID=2172681545403007231' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4197314054054678728/posts/default/2172681545403007231'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4197314054054678728/posts/default/2172681545403007231'/><link rel='alternate' type='text/html' href='http://sqlsearch.blogspot.com/2008/12/cxpacket-wait-types.html' title='CXPACKET wait types'/><author><name>Ajay Varma</name><uri>http://www.blogger.com/profile/14835085313182660954</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4197314054054678728.post-6240405393715024702</id><published>2008-12-03T06:18:00.000-08:00</published><updated>2008-12-03T06:21:25.252-08:00</updated><title type='text'>SQL Server 2005 REBUILD\REORGANIZE Index using DMV's</title><content type='html'>--INDEXREBUILD 'ADVENTUREWORKS',50,90,5000,'REBUILD','OFF'&lt;br /&gt;--INDEXREBUILD 'ADVENTUREWORKS',30,60,5000,'REORGANIZE','OFF'&lt;br /&gt;&lt;br /&gt;Alter PROC INDEXREBUILD&lt;br /&gt;@DBNAME VARCHAR(100), -- Name of database&lt;br /&gt;@MIN_FRAG INT, -- Minimum fragmentation value&lt;br /&gt;@MAX_FRAG INT, -- Maximum fragmentation value&lt;br /&gt;@TABSIZE BIGINT, -- Table size in pages&lt;br /&gt;@INDEXTYPE VARCHAR(10), -- REBUILD or REORGANIZE&lt;br /&gt;@REBUILDOPT VARCHAR(10) = 'OFF' -- ONLINE REUILD option (available only for Enterprise editions)&lt;br /&gt;AS&lt;br /&gt;SET NOCOUNT ON&lt;br /&gt;BEGIN&lt;br /&gt;DECLARE @INDEXID INT;&lt;br /&gt;DECLARE @PARTITIONNUM BIGINT;&lt;br /&gt;DECLARE @PARTITIONS BIGINT;&lt;br /&gt;DECLARE @FRAG FLOAT;&lt;br /&gt;DECLARE @COMMAND NVARCHAR(4000);&lt;br /&gt;DECLARE @SQLSTRING NVARCHAR(1000);&lt;br /&gt;DECLARE @PARMDEFINITION NVARCHAR(2000);&lt;br /&gt;DECLARE @DBID INT&lt;br /&gt;DECLARE @PARTITIONCOUNT BIGINT;&lt;br /&gt;DECLARE @SCHEMANAME NVARCHAR(130); &lt;br /&gt;DECLARE @OBJECTNAME NVARCHAR(130); &lt;br /&gt;DECLARE @INDEXNAME NVARCHAR(130);&lt;br /&gt;DECLARE @OBJECTID INT;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;CREATE TABLE #INDEXSTATS&lt;br /&gt;(&lt;br /&gt;OBJNAME VARCHAR(130),&lt;br /&gt;IDXNAME VARCHAR(130),&lt;br /&gt;SCHNAME VARCHAR(130),&lt;br /&gt;AVG_FRAGMENTATION_IN_PERCENT FLOAT,&lt;br /&gt;TBLSIZE BIGINT&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;SET @COMMAND = 'SELECT O.NAME,&lt;br /&gt;I.NAME,&lt;br /&gt;S.NAME,&lt;br /&gt;AVG_FRAGMENTATION_IN_PERCENT,&lt;br /&gt;SUM(TOTAL_PAGES)&lt;br /&gt;FROM SYS.DM_DB_INDEX_PHYSICAL_STATS ('+ CAST(DB_ID(@DBNAME) AS VARCHAR(3)) +', NULL, NULL, NULL, NULL) V&lt;br /&gt;JOIN ['+ @DBNAME +'].SYS.OBJECTS AS O ON V.OBJECT_ID = O.OBJECT_ID&lt;br /&gt;JOIN ['+ @DBNAME +'].SYS.SCHEMAS AS S ON S.SCHEMA_ID = O.SCHEMA_ID&lt;br /&gt;JOIN ['+ @DBNAME +'].SYS.INDEXES AS I ON I.OBJECT_ID = O.OBJECT_ID&lt;br /&gt;AND V.INDEX_ID = I.INDEX_ID&lt;br /&gt;JOIN ['+ @DBNAME +'].SYS.PARTITIONS AS P ON P.OBJECT_ID = O.OBJECT_ID&lt;br /&gt;JOIN ['+ @DBNAME +'].SYS.ALLOCATION_UNITS A ON P.PARTITION_ID = A.CONTAINER_ID&lt;br /&gt;WHERE AVG_FRAGMENTATION_IN_PERCENT &gt;= '+ CAST(@MIN_FRAG AS VARCHAR(8)) + '&lt;br /&gt;AND AVG_FRAGMENTATION_IN_PERCENT &lt;= '+ CAST(@MAX_FRAG AS VARCHAR(8)) + '&lt;br /&gt;AND I.INDEX_ID &gt; 0&lt;br /&gt;GROUP BY O.NAME,&lt;br /&gt;I.NAME,&lt;br /&gt;S.NAME,&lt;br /&gt;AVG_FRAGMENTATION_IN_PERCENT&lt;br /&gt;HAVING SUM(TOTAL_PAGES) &gt;= ' + CAST(@TABSIZE AS VARCHAR(50)) + ''&lt;br /&gt;&lt;br /&gt;INSERT INTO #INDEXSTATS &lt;br /&gt;( &lt;br /&gt;OBJNAME,&lt;br /&gt;IDXNAME,&lt;br /&gt;SCHNAME,&lt;br /&gt;AVG_FRAGMENTATION_IN_PERCENT,&lt;br /&gt;TBLSIZE&lt;br /&gt;)&lt;br /&gt;EXEC(@COMMAND)&lt;br /&gt;&lt;br /&gt;SET @COMMAND = ''&lt;br /&gt;&lt;br /&gt;DECLARE TAB CURSOR FOR &lt;br /&gt;SELECT OBJNAME,&lt;br /&gt;IDXNAME,&lt;br /&gt;SCHNAME&lt;br /&gt;FROM #INDEXSTATS;&lt;br /&gt;&lt;br /&gt;OPEN TAB;&lt;br /&gt;&lt;br /&gt;FETCH NEXT&lt;br /&gt;FROM TAB&lt;br /&gt;INTO @OBJECTNAME, @INDEXNAME, @SCHEMANAME;&lt;br /&gt;&lt;br /&gt;WHILE @@FETCH_STATUS = 0&lt;br /&gt;BEGIN;&lt;br /&gt;IF @INDEXTYPE = 'REBUILD'&lt;br /&gt;BEGIN&lt;br /&gt;IF @REBUILDOPT = 'ONLINE'&lt;br /&gt;SET @COMMAND = N'ALTER INDEX [' + @INDEXNAME + N'] ON [' + @DBNAME + N'].[' + @SCHEMANAME + N'].[' + @OBJECTNAME + N'] REBUILD WITH (FILLFACTOR = 90,ONLINE = ON)';&lt;br /&gt;ELSE&lt;br /&gt;SET @COMMAND = N'ALTER INDEX [' + @INDEXNAME + N'] ON [' + @DBNAME + N'].[' + @SCHEMANAME + N'].[' + @OBJECTNAME + N'] REBUILD WITH (FILLFACTOR = 90,ONLINE = OFF)';&lt;br /&gt;END&lt;br /&gt;ELSE&lt;br /&gt;SET @COMMAND = N'ALTER INDEX [' + @INDEXNAME + N'] ON [' + @DBNAME + N'].[' + @SCHEMANAME + N'].[' + @OBJECTNAME + N'] REORGANIZE';&lt;br /&gt;&lt;br /&gt;SELECT'EXECUTING: ' + @COMMAND;&lt;br /&gt;print @COMMAND &lt;br /&gt;--EXEC (@COMMAND);&lt;br /&gt;&lt;br /&gt;FETCH NEXT&lt;br /&gt;FROM TAB&lt;br /&gt;INTO @OBJECTNAME, @INDEXNAME, @SCHEMANAME;&lt;br /&gt;END;&lt;br /&gt;&lt;br /&gt;CLOSE TAB;&lt;br /&gt;DEALLOCATE TAB;&lt;br /&gt;&lt;br /&gt;DROP TABLE #INDEXSTATS&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;------&lt;br /&gt;To run this SP against All Database use below cursor.&lt;br /&gt;&lt;br /&gt;--Cursor for runing the procedure on all database.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Declare @DbName varchar(100)&lt;br /&gt;Declare @cmd varchar(100)&lt;br /&gt;&lt;br /&gt;Declare Reindex_cur cursor for &lt;br /&gt;&lt;br /&gt;select name from sysdatabases where dbid&gt;4&lt;br /&gt;open Reindex_cur fetch next from Reindex_cur into @DbName&lt;br /&gt;while (@@fetch_status = 0)&lt;br /&gt;&lt;br /&gt;begin&lt;br /&gt;&lt;br /&gt;Set @cmd='INDEXREBUILD '''+@DbName+''',50,90,5000,''REBUILD'',''ONLINE'''&lt;br /&gt;&lt;br /&gt;EXEC( @cmd)&lt;br /&gt;&lt;br /&gt;fetch next from Reindex_cur into @DbName&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;close Reindex_cur&lt;br /&gt;deallocate Reindex_cur&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4197314054054678728-6240405393715024702?l=sqlsearch.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlsearch.blogspot.com/feeds/6240405393715024702/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4197314054054678728&amp;postID=6240405393715024702' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4197314054054678728/posts/default/6240405393715024702'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4197314054054678728/posts/default/6240405393715024702'/><link rel='alternate' type='text/html' href='http://sqlsearch.blogspot.com/2008/12/sql-server-2005-rebuildreorganize-index.html' title='SQL Server 2005 REBUILD\REORGANIZE Index using DMV&apos;s'/><author><name>Ajay Varma</name><uri>http://www.blogger.com/profile/14835085313182660954</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
