| Author |
Topic |
|
loknathmahato
Starting Member
27 Posts |
Posted - 2011-12-12 : 14:06:08
|
| Hi Friends,I have implemented Log shipping on my MS SQL server 2008 database but at the weekend i am facing a major issue regarding log file. At the end of the week when we do maintenance of our database we have to perform major deletion on our database due to that log file size grow up to 20 GB thereafter we perform re-indexing then the size grow up to 25 GB or more. That is not affordable because if we go with this size then next week we perform same thing then the log file size would be double.So can somebody suggest me that what i have to do?Can i shrink the database?Will shrink affect the Log shipping?My average MDF file size is within 15 GB .Thanks |
|
|
jeffw8713
Aged Yak Warrior
819 Posts |
Posted - 2011-12-12 : 14:18:10
|
| You do not want to shrink the log file, or the database. The log file will grow to the size it needs to be to support your transactions. By shrinking it on a regular basis, all you are doing is causing performance issues when it has to grow again.If your database is in simple recovery, then the log file space will be marked as reusable by the system. If your database is in full or bulk_logged recovery model, the log file space will be marked as reusable after a transaction log backup. You should have regular scheduled transaction log backups (recommendation is every 15 minutes - at least) for any databases in full or bulk_logged recovery models.If the above is set correctly, the log file will stabilize at the size it needs to be and won't grow anymore.Jeff |
 |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2011-12-12 : 16:03:27
|
| The log file won't be double if you do the same next week. The log space is reusable, so the file will hit a steady size. If it needs to be 25GB for the index rebuilds, then leave it at 25GB.--Gail ShawSQL Server MVP |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2011-12-13 : 06:29:49
|
| Our daily-delete-maintenance takes about 45 minutes.We schedule an additional Log Backup to run every 2 minutes for an hour starting from the same time as the daily maintenance routine. That way the LDF file does not grow excessively just to accommodate the maintenance task. We have more Log Backup Files, but in total they are about the same overall size.The database files on the database you are log-shipping TO will be the exact same size as the ones the log files are coming FROM.The size of the 25GB log shipping files might cause some issues though - disk full, network traffic, and so on ... |
 |
|
|
pnash
Starting Member
26 Posts |
Posted - 2011-12-13 : 07:03:32
|
| Here is a very good article http://sqlskills.com/BLOGS/PAUL/post/A-SQL-Server-DBA-myth-a-day-(930)-data-file-shrink-does-not-affect-performance.aspx |
 |
|
|
johntech
Yak Posting Veteran
51 Posts |
Posted - 2011-12-13 : 09:54:34
|
| The Sql.log file may consume all disk space and cause SQL Server to run slowly when you turn on ODBC Tracinghttp://support.microsoft.com/kb/268591 |
 |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2011-12-13 : 13:55:17
|
quote: Originally posted by johntech The Sql.log file may consume all disk space and cause SQL Server to run slowly when you turn on ODBC Tracinghttp://support.microsoft.com/kb/268591
That's talking about a .log file, not the transaction log (which the OP is referring to)--Gail ShawSQL Server MVP |
 |
|
|
johntech
Yak Posting Veteran
51 Posts |
Posted - 2011-12-14 : 08:22:05
|
Hi Gila Monster I copy that from the Locknth we have to perform major deletion on our database due to that log file size grow up to 20 GB So I didn't know the difference------------------------------------------------------But look to belowIntroduced in SQL Server 7.0 was the ability automatically grow and toshrink the physical size of database data and transaction log files.Auto grow of files doesn't happen before the file is full, it happenswhen new space is needed (like when an insert is performed), so theuser will wait the time it takes to grow until the modification iscompleted.Auto grow and shrink can be very useful under special circumstances,for example after archiving data to some other location. However, weoften see DBA's doing shrink on a regular basis and the purpose of thisarticle is to explain some of the downsides of shrink and what actuallyhappens when you shrink a database file. Also, it is worth noticingthat the auto grow functionality was mainly added so the dba wouldn'tbe paged in the middle of the night because the database is full. Itwas never intended to be a high performance feature or to replace theneed to manage space usage, especially at the high endAcknowledgementsI like to thank SQL Server MVP Mark Allison,http://www.markallison.co.uk, who has provided valuable suggestions andinput for this article.Versions of SQL ServerThis article applies to SQL Server 7.0, 2000 and 2005, where not notedotherwise.More informationYou can shrink a database file using either DBCC SHRINKDATABASE (whichtargets all files for the database) or DBCC SHRINKFILE (which targets aparticular database file). I prefer SHRINKFILE. I will not go throughthe details of the commands here; they are documented in SQL ServerBooks Online. Let us first determine what actually happens when youshrink a database file:Shrinking of data fileWhen you shrink a data file, SQL Server will first move pages towardsthe beginning of the file. This frees up space at the end of the fileand the file can then be shrunk (or as I like to view it: "cut off atthe end").Shrinking of transaction log fileSQL Server cannot move log records from the end of the log file towardthe beginning of the log file. This means that SQL Server can only cutdown the file size if the file is empty at the end of the file. Theend-most log record sets the limit of how much the transaction log canbe shrunk. A transaction log file is shrunk in units of Virtual LogFiles (VLF). You can see the VLF layout using the undocumented DBCCLOGINFO command, which returns one row per virtual log file for thedatabase:DBCC LOGINFO('myDatabase')FileId FileSize StartOffset FSeqNo Status Parity CreateLSN2 253952 8192 11 0 128 02 253952 262144 13 0 128 02 270336 516096 12 0 128 70000000250002882 262144 786432 14 2 128 9000000008400246The interesting column is "Status". 0 means that the VLF is not in useand 2 means that it is in use. In my example, I have 2 at the end ofthe file (read result from top to bottom) and this means that the filecannot currently be shrunk.In 7.0, you have to generate dummy transactions so that the usage ofthe log file wraps toward the beginning of the file. You can then emptythe log file using BACKUP LOG and then shrink the file.In SQL Server 2000, the generation of dummy log records is done for youwhen you execute the DBCC SHRINKFILE command.What you end up doing is BACKUP LOG, DBCC SHRINKFILE several times.Investigate the layout of the log file using DBCC LOGINFO in between.If you have loads of VLF (many rows returned from DBCC LOGINFO), youprobably had a small file size for the log initially and then had lotsof small autogrow. Having lots of VLF is a bit of a performance hit. Ifthis is your case, consider shrinking the log file to a very small sizeand then expand the file size to something comfortable (a bigger size).Here are some articles specifically about management of log file size:How to Shrink the SQL Server 7.0 Transaction LogShrinking the Transaction Log in SQL Server 2000 with DBCC SHRINKFILELog File Grows too bigLog file filling upConsiderations for Autogrow and AutoShrinkFromhttp://bytes.com/topic/sql-server/answers/527336-transaction-log-keeps-growing |
 |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2011-12-14 : 11:01:20
|
| Yes, and???--Gail ShawSQL Server MVP |
 |
|
|
|