Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 help with large db and log files

Author  Topic 

khunkao
Starting Member

8 Posts

Posted - 2009-05-01 : 11:58:51
I don't have much space left on this drive and I'm always on the brink of running out of space because of the growing log files.
This is a SQL2000 database that is over 5GB and the transaction logs are constantly growing and filling the space up (lots of transactions during the day).

I seem to have a basic understanding of dbcc shrinkfile but what about shrinkdatabase and this truncate_only?

What is a simple script I can run to maintain this so it doesn't get out of hand?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-05-01 : 13:11:08
What is your database recovery model set to? If it's not SIMPLE, then are you performing regular transaction log backups? We backup our tlogs every 15 minutes.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

khunkao
Starting Member

8 Posts

Posted - 2009-05-01 : 13:58:39
I have it set to Bulk-logged. Is that a good thing?

quote:
Originally posted by tkizer

What is your database recovery model set to? If it's not SIMPLE, then are you performing regular transaction log backups? We backup our tlogs every 15 minutes.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-05-01 : 15:15:10
It depends. What kind of recovery do you require in case of a failure?

And most importantly, how often do you backup the transaction log?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

khunkao
Starting Member

8 Posts

Posted - 2009-05-01 : 16:01:42
I would like to definitely have the entire database structure and log file if possible. Rolling back too far isn't necessary but it should be recent.
I use Veritas to backup the mdf and log though it doesn't do any maintenance on the db itself.


quote:
Originally posted by tkizer

It depends. What kind of recovery do you require in case of a failure?

And most importantly, how often do you backup the transaction log?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-05-01 : 16:43:49
Do not use Veritas to backup the databse files. It is pointless to do this as you may not be able to recover from these. Have Veritas sweep the backup file (.bak) to tape.

It doesn't sound like you require BULK_LOGGED or FULL recovery model, since it sounds like you fall back to the last full backup. I'd recommend switching your recovery model to SIMPLE and then shrinking the log file down to about 25% of the size of the mdf file (DBCC SHRINKFILE for this task).

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-05-01 : 16:44:28
Oh and I'll assume you don't have any transaction log backups running since you didn't provide that information the two times I asked.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

khunkao
Starting Member

8 Posts

Posted - 2009-05-01 : 17:23:20
Well I thought the full backup included the trans-logs?

quote:
Originally posted by tkizer

Oh and I'll assume you don't have any transaction log backups running since you didn't provide that information the two times I asked.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-05-01 : 17:25:46
Nope, that's why you have such a bloated transaction log file.

To see what my production environments look like, check this: http://weblogs.sqlteam.com/tarad/archive/2008/06/30/SQL-Server-jobs-on-production-instances.aspx

Notice the second item which shows I backup the transaction logs every 15 minutes.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-05-01 : 17:26:30
So you have two choices:
1. Schedule regular transaction log backups, perhaps hourly.
2. Switch your recovery model to SIMPLE.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-05-01 : 17:34:45
quote:
Well I thought the full backup included the trans-logs?
Beginning with SQL Server 2000, it does. However a full or differential backup DOES NOT clear the transaction log. Those transactions will remain unless you truncate or back up the log.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-05-01 : 17:37:43
Well you can't use the full backup to restore to a point in time, so that's why I said it doesn't include the tlog information.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-05-01 : 19:32:37
Ugh, sorry, didn't see that this was a 2000 database. Never mind, pretend I wasn't here.
Go to Top of Page

khunkao
Starting Member

8 Posts

Posted - 2009-05-04 : 09:25:31
So do you recommend I just switch to SIMPLE instead? Or do a regular tlog backup (scheduled through Maintenance?). I guess the easiest way is to go into SQL Enterprise Manager, pull up my Database and change the recovery model to SIMPLE instead of Bulk-Logged. Can I do this while things are running or whenever.
What exactly does switching to SIMPLE do in terms of trans-logs.

quote:
Originally posted by tkizer

Well you can't use the full backup to restore to a point in time, so that's why I said it doesn't include the tlog information.


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-05-04 : 12:45:20
We can't recommend to you which one to pick as it depends on your business requirements which should include recovery capabilities. In the case of a failure, can you afford to revert back to the last good full backup or do you need more up to date data? We require a maximum of 15 minutes of data loss, we that's why we use FULL recovery model and backup our transaction logs every 15 minutes.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

khunkao
Starting Member

8 Posts

Posted - 2009-05-04 : 13:20:06
quote:
Originally posted by tkizer

We can't recommend to you which one to pick as it depends on your business requirements which should include recovery capabilities. In the case of a failure, can you afford to revert back to the last good full backup or do you need more up to date data? We require a maximum of 15 minutes of data loss, we that's why we use FULL recovery model and backup our transaction logs every 15 minutes.
I can afford to revert back to the last good backup. If i need to revert back to something during the day I would say a full backup every night would be reasonable. I don't need to have to roll back 15 minutes ago.
Is there a simple script I can run to do this? Also the 5GB database is huge, anyway to shrink that down as well or is that not recommended?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-05-04 : 13:30:48
What simple script are you referring to?

A 5GB database is tiny, so I'm not sure why you'd want to shrink it. How big is the MDF file and how big is the LDF file?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

khunkao
Starting Member

8 Posts

Posted - 2009-05-04 : 13:59:14
I thought there might be a backup script I can run

The MDF is 5.8GB and the LDF is around 786MB.

quote:
Originally posted by tkizer

What simple script are you referring to?

A 5GB database is tiny, so I'm not sure why you'd want to shrink it. How big is the MDF file and how big is the LDF file?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-05-04 : 14:32:51
Those file sizes sound reasonable.

Here's the script that I wrote and use in all my environments: http://weblogs.sqlteam.com/tarad/archive/2009/04/07/Backup-SQL-Server-DatabasesAgain.aspx

And here's what my production environments look like as far as SQL jobs: http://weblogs.sqlteam.com/tarad/archive/2008/06/30/SQL-Server-jobs-on-production-instances.aspx

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

khunkao
Starting Member

8 Posts

Posted - 2009-05-04 : 17:09:21
I saw your scripts, much too advanced for me. But I understand the gist of it.
Just off the topic, are there any free resources or self-tutorials I can read to get up to speed on SQL? I've touched a little bit on SQL before but definitely not enough real world experience.

quote:
Originally posted by tkizer

Those file sizes sound reasonable.

Here's the script that I wrote and use in all my environments: http://weblogs.sqlteam.com/tarad/archive/2009/04/07/Backup-SQL-Server-DatabasesAgain.aspx

And here's what my production environments look like as far as SQL jobs: http://weblogs.sqlteam.com/tarad/archive/2008/06/30/SQL-Server-jobs-on-production-instances.aspx

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-05-04 : 17:10:24
You don't need to understand the scripts from my blog. You just need to call them in SQL jobs and pass the appropriate parameters.

I don't have any free tutorials, but if you search for madhi in the forums, check out his signature.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
    Next Page

- Advertisement -