Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Shrink tlog while mirroring a database

Posted on 2009-04-14
9
Medium Priority
?
614 Views
Last Modified: 2012-05-06
Hello all,

I am trying to find information on the best way to shrink a transaction log while the database is being mirrored. Typically I set the recovery to simple and then run dbcc shrinkfile to bring the tlog down. With mirroring this is not possible as the mirror must be in Full recovery mode. My question then is two fold.
1.) Can a transaction log be shrunk while mirroring? Since the db is in full recovery mode and I run dbcc shrinkfile I usually get an error message unless I set recovery to simple.
2.) If I do set recovery to simple while mirroring what happens to the mirror and if it breaks is there a quick method for reestablishing the mirror?

I appreiciate anyone's help.

Keith
0
Comment
Question by:kwoznica
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 60

Expert Comment

by:chapmandew
ID: 24141592
1.  sure
2.  No

remember, truncating the log is different than shrinking the file.  If you're doing regular log backups (hopefully you are) then you can just use dbcc shrinkfile to shirnk the log file.
0
 
LVL 15

Expert Comment

by:rob_farley
ID: 24144374
The only way to clear up space inside a transaction log (also known as truncating) if the database is in the Full Recovery Model (as is required by mirroring) is to back it up.

So back it up regularly. Like... every few minutes. You don't need to keep the file if you're not interested in it (and clearly you're not if you're used to setting the database to Simple). If you do this, the transaction log shouldn't grow much, and you shouldn't need to shrink the log file at all (which ultimately just makes it have to grow more often - and growing log files is a painful operation).

Honestly - you should be trying to avoid having to shrink log files. I think it's only very exceptional circumstances that should make you want to shrink a log file.

Rob
0
 

Author Comment

by:kwoznica
ID: 24147505
Rob,

I understand your point about backups. During the day we do run log backups. The issue that I have is on weekends we also run a reorginize on the database to keep the database efficient and also as compact as possible. It is during this maintenance task that the log file will fill up to 120GB. I also run tlog backups during the maintenance reorginize but drive space has become an issue. This is the reason I will run dbcc shrinkfile.

In a circumstance such as this what would you recommend?
0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
LVL 60

Expert Comment

by:chapmandew
ID: 24147546
Since you can't switch to Bulk Logged (because you're doing mirroring), you're better off doing what you're thinking about doing a shrink after a log backup.
0
 
LVL 15

Expert Comment

by:rob_farley
ID: 24153667
You should remember that if you're mirroring, then that 120GB of log will have to be sent to the mirror as well.

Depending on how large your database is, you may prefer to stop mirroring, switch to Simple, do your reorg, then switch back to Full and re-establish your mirroring.

Or else ask yourself why you really need to do a reorg? Are you checking for index fragmentation before rebuilding them, for example?

Rob
0
 

Author Comment

by:kwoznica
ID: 24396550
Rob,

I appreciate your suggestions. I am going to look into scripting out a job for switching back from mirroring, Simple mode, reorg, Full and back to the mirror.

I have to ask you one more question based on your last question. Should I check for index fragmentation and if so based on what statistical value should I kick off a reorg?

Thanks. The points are yours.

Keith
0
 
LVL 15

Accepted Solution

by:
rob_farley earned 2000 total points
ID: 24408866
Keith,

It's all going to depend on how you feel your performance is being hit. If you're largely doing Seeks on your index, then you will barely notice fragmentation, because each Seek will still take about 3 reads.

If you're scanning, then you'll be following quite a few more links than you would ordinarily need, and this is where the pain will come in.

Unfortunately, it's like the length of string. Some people feel fragmentation pain early, some people can have massive amounts of fragmentation and really not care.

Definitely check the level of fragmentation before reorganising an index. It's not worth the pain if you don't need it. But also make sure you've baselined your performance, so that you can work out what pain you're experiencing (before and after). See what happens (preferably on a test machine) if you ignore the fragmentation a bit longer, etc... but definitely monitor what the fragmentation is like, to try to get a feel for what you should do.

Also bear in mind that tables will have different uses. Some will bear much higher levels of fragmentation, while others will hurt you quite quickly. The better you understand these different levels, the better time you'll have managing it.

Rob
0
 

Author Closing Comment

by:kwoznica
ID: 31570110
Rob, I appreciate your time in making your response. It is people like you that help a young dba like myself make progress. Thanks.
0
 
LVL 15

Expert Comment

by:rob_farley
ID: 24478555
No problem - any time.

Rob
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

722 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