Solved

SQL Server 2014 reindex maintenance plans

Posted on 2016-09-07
8
57 Views
Last Modified: 2016-09-21
i have a maintenance plan setup to run a weekly index.  Within the maintenance plan i have a rebuild index task and a reorganize index task.  I just wanted to ask the experts if it is recommended to do both or if i could just use the rebuild task and not worry about reorganizing index task.  

I want to avoid the huge log file that is created when running the reorganizing index task but i don't want to eliminate the reorganizing index task if it is something that will be important.

Also, i should mention that the job that includes reorg and rebuild is failing due to the log file filling up.  Maybe i can change settings for the log file to allow a bigger one and then run the job nightly instead of weekly...

Any thoughts?
0
Comment
Question by:IKtech
  • 3
  • 3
  • 2
8 Comments
 
LVL 39

Accepted Solution

by:
lcohan earned 250 total points
ID: 41788471
1. No matter what anyone will say in my opinion (and not only me) REBUILD does way more than REORG and I would always use REBUILD if I have a server running enterprise edition like it looks you have.
2. If you run REBUILD then REORG is a waste assuming all indexes are rebuilt. Speaking of that...there are various extremely well written and working scripts available to only REBUILD indexes where fragmentation is greater than xx% so your T-log would not grow as if you rebuild ALL. For instance this one: https://ola.hallengren.com/sql-server-index-and-statistics-maintenance.html 

Also, some indexes will show fragmentation right after rebuild/reorg because of their composition and fillfactor so...I would not just rebuild ALL by default.
3. If you can change the Recovery option to SIMPLE indeed the T-log growth will be smaller but..you will lose the fast recovery option as T-Log backups cannot be taken. I would try first as mentioned a filtered REBUILD and maybe do it once as you said manual and monitor the T-log growth and when is getting close to get full just take a T-log backup to reclaim the space. After that a daily REBUILD filtered should not fill the T-Log because only fragmented indexes will be rebuilt.
0
 
LVL 3

Author Comment

by:IKtech
ID: 41788500
Thanks Icohan!!  i'll give it a shot...
0
 
LVL 39

Expert Comment

by:lcohan
ID: 41788505
Just caution with CLUSTERED INDEXES as they can also be rebuilt with ONLINE = ON but...performance may suffer in particular while these ones are done and a decrease in performance should be expected in general while indexes are rebuilt due to resource consumption but if your database is not backend to a 24/7 system you should have no issues to do that during off-hours.

 Also, do not change Recovery option of a production database without checking existing backup/restore and disaster recovery policies internal to your place.
0
 
LVL 46

Assisted Solution

by:Vitor Montalvão
Vitor Montalvão earned 250 total points
ID: 41789171
Most of DBAs I know follows Microsoft's recommendation and that's includes Ola Hallengren.
Fragmentation level:
> 5% and < = 30% ALTER INDEX REORGANIZE
> 30% ALTER INDEX REBUILD WITH (ONLINE = ON)


To reduce the use of transaction log you can use the option SORT_IN_TEMPDB = ON but maybe your transaction log is not correctly sized and better to provide in advance the necessary disk space.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 3

Author Comment

by:IKtech
ID: 41807205
I removed the reorg task and just do a rebuild.  Also the max size for the transaction log was increased.  Things seem to be running well at the moment.  Thanks!
0
 
LVL 39

Expert Comment

by:lcohan
ID: 41807212
Make sure you take regular T-log backups - ideally one as soon as the rebuild is done so the space is recycled/release back to use inside the T-log file.
0
 
LVL 3

Author Comment

by:IKtech
ID: 41807217
it's done hourly...
0
 
LVL 46

Expert Comment

by:Vitor Montalvão
ID: 41808155
I removed the reorg task and just do a rebuild
Technically it's a solution that works but in my opinion this is a waste of resources (CPU, Memory and Storage) and will cause more locks during the rebuild task.
REORG is there for a reason and not using it won't bring any harm but using it will bring benefits in terms of limiting the resource usage.
Cheers
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
grouping logic 6 46
Add '#' to end of file 2 29
SQL Field Length for Email Address 3 14
ms sql last 8 weeks as columns 5 7
When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now