November 10, 2014 at 9:59 am
We are faced with shortage of drive space and the majority of the space is taken up by very large log files. I have log files as large as 15GB. We have been shrinking the log files only when needed.
Question: Is there harm in shrinking the log files once a week?
USE UserDB;
GO
ALTER DATABASE UserDB
SET RECOVERY SIMPLE;
GO
DBCC SHRINKFILE (UserDB_Log, 1);
GO
ALTER DATABASE UserDB
SET RECOVERY FULL;
GO
November 10, 2014 at 10:07 am
Please don't.
If you switch to SIMPLE recovery, you'll lose the ability to perform point-in-time recovery. You can do it temporarily, for instance during ETL loads, but right after switching back to FULL recovery you need a full backup to initialize the log chain.
If you want a smaller transaction log file, take more frequent log backups.
-- Gianluca Sartori
November 10, 2014 at 10:22 am
How often are you running full/diff backups compared to transaction log backups? That would determine how long you need to hang onto your old tlog backups before you can delete them.
November 10, 2014 at 10:38 am
Yes, LOTS of harm. Among the issues are VLF problems (search Kimberly Tripp VLF), stalls while you grow back out, you probably have default 10% growth increment which makes this even worse, OS disk frag too.
15GB is a SMALL file these days!! What is database size?
Have you tried to track tlog usage back to the source? Perhaps things are just done poorly in the app/etl process, etc.
Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service
November 10, 2014 at 10:44 am
Thank you so much. I've over looked the point-in-time restore ability. We are currently performing transaction log backups every 15 minutes. I wonder if we are over looking other best practice steps.
Thank you for taking the time.
November 10, 2014 at 10:54 am
This is interesting. Currently, our Diff runs every Wednesday and Full every Sunday.
Base on our current scenario, what is the formula for how long we should keep our log file backups?
November 10, 2014 at 11:00 am
Thanks. I am researching "Kimberly Tripp VLF" now. Yes our growth is defaulted to 10% growth and I do not see a scheduled disk defrag process in place.
I will track usage back to the source. I'm sure you are correct and hit the nail in the head with poorly done app/etl processes.
Thanks again for taking the time.
November 10, 2014 at 11:21 am
Note that FAR worse than the 10% log file growth is the 1MB default data file growth increment. If you have that, well, you have a BUTT TON of little IO-performance-robbing 1MB file chunks spread all over your storage media! :w00t:
Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service
November 10, 2014 at 11:49 am
I'd like to know where so many people got the idea that the database should be set to Simple Recovery Mode first.
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
November 10, 2014 at 11:55 am
Alvin Ramard (11/10/2014)
I'd like to know where so many people got the idea that the database should be set to Simple Recovery Mode first.
Bad habits from DTS when I used to work in SQL 2k before I understood recovery properly and reading recommendations back then. I've learned better since then but a lot of those bad practices are still out there, percolating around the net. It's also one of the first things you run into when you look at log files is that recovery mode affects the size and you should decide what to do with it.
At first glance, set it to simple, do your work, switch it back sounds like a reasonable idea when you just don't know the impact.
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
November 10, 2014 at 11:55 am
I think it goes back to before backup with truncate only was depcrecated. Switching to simple then shrinking the log file then switching back has pretty much the same consequences but requires a few more steps to make sure you really really want to do that.
November 11, 2014 at 9:16 am
Thank you for everyone's input. Y'all are very helpful.
November 11, 2014 at 9:57 am
scantoria (11/10/2014)
This is interesting. Currently, our Diff runs every Wednesday and Full every Sunday.
With once a week fulls i'd prefer more regular diffs
scantoria (11/10/2014)
Base on our current scenario, what is the formula for how long we should keep our log file backups?
you should keep the logs back to at least the last full backup, to give your self the most flexible restore routes.
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
Viewing 13 posts - 1 through 12 (of 12 total)
You must be logged in to reply to this topic. Login to reply