SQL 2008 log files

New SQL 2008 server.  I back up my databases, I back up my log files.  In SQL 2003 I remember this would reduce the size of the log files until the next back up window.  It doesn't reduce the log file size in 2008.  Does it work different?  Am I missing a step?
LVL 1
damelahnAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lcohanDatabase AnalystCommented:
"In SQL 2003 I remember this would reduce the size of the log files until the next back up window."
First there's no SQL 2003 - maybe 2005 and secondly it "...would NOT reduce the size of the log files until the next back up window." but recycle the space inside the log so it can be re-used without the log to grow.

What is the Recovery option of the database where you are having issues with the T-Log file?
How often do you backup the T-log?
0
wnrossCommented:
If you have only one log file (normal) you will be unable to shrink the transaction log manually, since the server needs to be able to close a file to shrink it.  Note that truncation occurs automatically only under the simple recovery model, so if you are not using that you will not see a change in file size.

Try adding a second log file to the database then issue a DBCC shrinkfile command
USE UserDB;
GO
DBCC SHRINKFILE (DataFile1, 7);
GO

Open in new window


Copied right from MSDN:
If the shrink operation runs without error, but the file does not appear to have changed in size, verify that the file has adequate free space to remove by performing one of the following operations:

Run the following query.
   
SELECT name ,size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0 AS AvailableSpaceInMB
    FROM sys.database_files;

Open in new window

0
damelahnAuthor Commented:
Sorry, old server was sql 2000 (not 2003).  Recovery is set to Full and t-log backups run every 2 hrs during business hours.  

So you are saying the log file size will always increase and never decrease in this mode?
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Aneesh RetnakaranDatabase AdministratorCommented:
>So you are saying the log file size will always increase and never decrease in this mode?
If you see the log file size increase even after taking the log backups, there seems like bigger transactions going one, could be more page splits, db shrinking or an increase in the no of transactions. make sure that auto shrink is not enables for the database; also you could try changing the log shipping to every 1 hr instead of 2 hrs. look for  other jobs like reindexing check db etc.
0
lcohanDatabase AnalystCommented:
Indeed - The T-Log file size will never decrease on its own unless you set the AUTOSHRINK database option (definitely NOT recommended)  to ON so the file size is automatically reduced OR you shrink the T-log file from the SSMS UI menu (not recommended) or by running a DBCC SHRINKFILE(dbnameHere_log) SQL command.


T-log SQL backups would only recycle the space inside the physical file and you could do it more often if you need to keep the size of the log under control OR switch the recovery mode to BULCK-LOGGED without ANY impact to your FULL/T-log and recovery planning OR you may even switch it to SIMPLE but that ONLY if your business model can accept less logging and implicit some data loss plus this SIMPLE recovery will impact your backups type and schedule.
0
Steve WalesSenior Database AdministratorCommented:
Your transaction log file will grow to accommodate the volume of transactions that occur between your transaction log backups.  It is the backup of the log that marks the space in the TLog file able to be reused.  

Perform a log shrink after every backup is counter productive.  The space might be marked as able to be reused in the log file, this allowing a shrink, but if you have 20 GB of transactions in between log file backups, then it's just going to grow back to 20 GB.

If you are concerned about the size of your transaction log file, perform your log file backups on a more frequent basis - hourly, half hourly, whatever meets the needs of your business requirements (some people run log backups every 60 seconds).

If you know that volume of your transactions, you can size your log file accordingly ahead of time, and prevent automatic log file growth operations during peak periods (which is an expensive operation).
0
damelahnAuthor Commented:
I manually backed up one of the smaller DBs and the associated log file.  Switched the DB to Simple mode, waited a bit and then switched back to Full.  Now I have a brand new (tiny) log file.  Any harm done by using this method?
0
Steve WalesSenior Database AdministratorCommented:
Switching a database to simple recovery mode breaks your recovery chain.  If it's a prod database, take a new full backup immediately.    That's not something you should really ever do.

If you are concerned about a bloated log file, please read this article: http://www.experts-exchange.com/Database/MS-SQL-Server/A_11077-How-to-shrink-a-bloated-log-file.html

It also includes links to several other references that will explain why your log file is growing, how to shrink it to reclaim space and then how to size it correctly to prevent the problem happening again.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wnrossCommented:
So you are saying the log file size will always increase and never decrease in this mode?
If your server is set to "Full Recovery" then the transaction logs can only be reduced in size after a transaction log backup. Eg:
BACKUP LOG [UserDb] TO  DISK = N'C:\Backup\UserDb.bak'
GO

Open in new window

If your file sizes are getting too large you might want to look at your database properties like autogrow and autoshrink, however the autoshrink property probably should only be used in development databases.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.