Link to home
Start Free TrialLog in
Avatar of Eprs_Admin
Eprs_AdminFlag for Austria

asked on

log size of DB always changed

Hi Experts,

I have a DB on a SQL server 2008.
With a script I always check the log size of the DB.
But here the DB has always different log size and therefore the log is sometime 99% full and sometime not.
Which process changed the size of the log ?
I just want the log to be empty, this is done with my backup exec tool.
Avatar of Vikas Garg
Vikas Garg
Flag of India image

Hi,

Each Insert ,Update and Delete task will increase the log file size since it will be logged.

However you can control the size of the Log file by setting its File Size but it can't be emptied ...
Avatar of Eprs_Admin

ASKER

Yes this I know.
But why the log file size is changed all the time ?
I have another log file which has always the same size. maybe it is 20% filled but the size is always the same.
Some process is changing also the size.
Is the size increasing, or is it shrinking too? The log file will grow by itself (depending on configuration) when it needs to and can also be set to autoshrink (although that isn't recommended).

I'd start by double checking the configuration of the log file and what settings have been applied.
it is growing and shrinking.
On my backup exec I have set for SQL : Backup and truncate Transaction log
You would most likely have autogrow enabled on your log.  You can view more about this and autoshrink here:
http://support.microsoft.com/kb/315512
You can view the setting of your database by issuing the following command:
sp_helpdb [ [ @dbname= ] 'yourdatabasename' ]

Open in new window

the command is not working
Where to put my db name in ?
SOLUTION
Avatar of Randy Poole
Randy Poole
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ok the DB is 22GB.
The log is 84MB with maxsize=unlimited and grow 1024KB.
But I cannot see the shrink parameters
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ok, autoshrink is set to true.
And size on start is 80MB.

Without impacts for the user, can I change both ?
Autoshrink to true
start size to 1GB

??
On my backup exec I have set for SQL : Backup and truncate Transaction log

That explains why it is shrinking a truncate deletes everything from the transaction log
You can.
thanks
I have the same setting on another DB, Backup and truncate Transaction log.
But this one stays the same size , no shrinking.
In SQL manager autoshrink is off.
>> On my backup exec I have set for SQL : Backup and truncate Transaction log

 That explains why it is shrinking a truncate deletes everything from the transaction log
<<

That's not correct.  In SQL Server, log "truncation" simply marks logical files in the log as available for reuse to store new log records.  A truncate does not "delete" anything in the log file, nor does it shrink the log file.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ok the size increased now to 19GB.
This is nearly the size of the DB itself.
Check the database's recovery model.  If it's "FULL", you'll have to back up the log before the space in it can be re-used.  If you don't want or need to do point-in-time recovery, change the recovery to SIMPLE and SQL will automatically re-use log space as soon as it can.

It's also technically possible that replication or some other process is holding log space.

You can determine both of those by looking at the output from:

SELECT * FROM sys.databases WHERE name = '<your_db_name>'
Recovery model is FULL.
As long as you are in FULL mode, then the log must be backed up, or it will continue to grow.  You'd have to change back to SIMPLE to avoid doing a log backup (and a backup on a 19GB log file will take a while).
of course the logs are backed up all two hours.
Thanks.