473,774 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please evaluate this approach to shrinking log files

I've been tasked with taking over the support for a client's SQL Server
database. I'm not a DBA by profession, I'm a software developer who
uses SQL Server as a database designer.

The clients have reported that the server is running out of disk space
and examination shows that the log files for several of the databases
are at 5Gb or more.

After reading around the subject I suggested the following sequence of
operations:

-- Select the name of the database you want to shrink
USE MyDB

-- Dump unwanted transactions
dump tran MyDB with truncate_only

-- Get the name of the logfile
SELECT * from sysfiles

-- Having examined the rows returned by this use the log file....

-- Shrink the file to required size (in MB)
DBCC SHRINKFILE('MyD B_log', 10)

Is this a reasonable approach? Please bear in mind that I'm pretty new
to this, and I have many other tasks to do besides manage the server.
A previous DBA has set up good maintenance plans etc. so everything is
being properly backed up (well, I think it is)

If this IS a good approach, would it be reasonable to do this on, say,
a monthly basis as a scheduled job? Obviously the step

SELECT * from sysfiles

which gives us the physical name of the log file would be removed and
the job would operate explicitly on each log file for each database in
turn.

Many thanks for reading.

William Balmer.

Sep 8 '06 #1
2 1567
A previous DBA has set up good maintenance plans etc. so everything is
being properly backed up (well, I think it is)
A common cause of unruly log files is that the database is in the FULL
recovery model but regular transaction log backups are not scheduled. Since
committed transactions won't get removed from the log until the log backup,
manual action is required to reduce the log size.

If you need to minimize data loss, the best approach is to schedule regular
log backups to run periodically between full database backups. You can
include this as part of a database maintenance plan. If more data loss is
acceptable (i.e. your plan is to simply restore from the last full backup),
you can use the SIMPLE recovery model so that committed data are
automatically removed from the log and you don't need to bother with log
backups.

In any case, the log should be sized to accommodate the activity between log
backups (FULL recovery) or the largest transaction (SIMPLE). The high-water
mark of this log space is simply the cost of doing business. IMHO, log file
shrinking should be done only after the log grows due to unusual activity.
I wouldn't schedule log shrinking because automating the process will only
hide the underlying cause.

Keep in mind that the number one responsibility of a DBA (or one that wears
a DBA hat) is to implement and test a backup/recovery plan. If you haven't
already done so, I suggest you run a restore test. You don't want any
surprises when you need to do it for real.
--
Hope this helps.

Dan Guzman
SQL Server MVP

"William" <wi***********@ hotmail.comwrot e in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
I've been tasked with taking over the support for a client's SQL Server
database. I'm not a DBA by profession, I'm a software developer who
uses SQL Server as a database designer.

The clients have reported that the server is running out of disk space
and examination shows that the log files for several of the databases
are at 5Gb or more.

After reading around the subject I suggested the following sequence of
operations:

-- Select the name of the database you want to shrink
USE MyDB

-- Dump unwanted transactions
dump tran MyDB with truncate_only

-- Get the name of the logfile
SELECT * from sysfiles

-- Having examined the rows returned by this use the log file....

-- Shrink the file to required size (in MB)
DBCC SHRINKFILE('MyD B_log', 10)

Is this a reasonable approach? Please bear in mind that I'm pretty new
to this, and I have many other tasks to do besides manage the server.
A previous DBA has set up good maintenance plans etc. so everything is
being properly backed up (well, I think it is)

If this IS a good approach, would it be reasonable to do this on, say,
a monthly basis as a scheduled job? Obviously the step

SELECT * from sysfiles

which gives us the physical name of the log file would be removed and
the job would operate explicitly on each log file for each database in
turn.

Many thanks for reading.

William Balmer.

Sep 8 '06 #2

Dan Guzman wrote:

snip

Many thanks, Dan - much to think about. I'll read up on the various
topics and may post later if I come up against a brick wall!

Thanks again

William Balmer

Sep 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2226
by: Jaeger | last post by:
Hi all. I'm having trouble shrinking a database. In short, using the SQL Query Analyzer, I enter the following commands: DBCC SHRINKDATABASE (database, 80) GO The command returns the expected 'DBCC execution completed.' response, but
1
2241
by: willie | last post by:
Hi all: I restored one backup database (7.9 GB mdf) on two diffrent servers. I shrunk them by clicking "Move pages to beginning of file before shrinking". After shrinking, one mdf file is 6.7 GB, and the other is 4.2GB. I shunk again and again: 1. the 6.7GB become 5.9GB, 5.2GB, 4.7GB and 4.2Gb (four times) 2. the 4.2Gb become 4.0GB (just one more time)
6
3096
by: Jens | last post by:
I have a database file LEAR_Index(yes, it hold index data) from a have have recently removed a bunch of data. It is about 120 Gb, 100Gb of which is not used. I wan´t to shrink the file to lean 30-40Gb. I´ve been trying this: dbcc shrinkfile('LEAR_Index',40000) But to no apparent avail; the file did not shrink.
1
1635
by: jeffreyv | last post by:
Hi! I'm studying to have my MCSE 70-228 certification and I'm trying some things with backing up transaction logs and shrinking it. Here's what I do: There is no activity in the database by the way. I have a transaction log of 1792 kb...
1
3294
by: news.xnet.hr | last post by:
Hi All! I'm doing a little app for browsing images(like ACDSee). All thumbnails are actually panels with imageboxes and labels for image properties (like ACDSee). What I'm doing is first fill the FileInfo with (image)files from selected folder. After that I have a loop for putting the thumbnails on the screen, on the right position(nothing special, just calling new thumbnail class derived from PanelClass per loop).
5
6804
by: Csaba Gabor | last post by:
In Firefox 1.5 (this question is Mozilla specific as I am using greasemonkey) I would like to be able to use document.evaluate to return the first TD entry that shows ^\s*MySearchText\s*$. As I understand it, xpath doesn't yet have regular expressions so I thought to do: function findNode (srch) { var node; var expr="//td"; var RE = new RegExp("\\s*" + srch + "\\s*$");
1
1286
by: | last post by:
Hi. This is a a semi-newbie question about how to store arbitrary information about my apps such that I can code quickly, mimizing complexity and the number of things I have to hold in my brain. I am going to describe the scheme I'm using, and then I'm going to describe another scheme that may be more OO but that I have not tried. I'm hoping someone vastly smarter and more experienced than me will critique this and/or tell me a yet...
3
1794
by: Sander Tekelenburg | last post by:
Situation: I store news articles as individual PHP files. Each file contains HTML and now and then some embedded PHP snippets. Serving those news articles on the Web works fine, through include(). But I want to also serve them through RSS, and found that in that case the PHP source code is served -- it's not being evaluated. So it seems obvious that I need to first evaluate those PHP snippets, store the result in a variable, and use...
0
1303
by: kazper | last post by:
Good day, I have some problems regarding my Hard disk space for my logs in SQL Server 2005. When I try shrinking the database it returns an error not letting me to do anything about the size of the file. Is there any way that I can delete the used transaction logs in my LOG File to free some disk space that I need. I cannot delete or add any new files on my database, because the transaction log file is full. My database is set AUTO GROW...
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10040
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6717
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.