|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: Wednesday, December 26, 2012 11:03 PM
Points: 586,
Visits: 2,195
|
|
Hi 1) At what time intervel does the simple recovery model truncates the trans Log 2) I am having a 30 million records i need to delete 25 million old records with minimum log how it can be done there will be continues users accessing the table
Thanks Parthi
Thanks Parthi
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 2:54 AM
Points: 37,692,
Visits: 29,951
|
|
1) Whenever a checkpoint occurs. Only log records up to the beginning of the oldest open transaction can be truncated. 2) Do it in batches and run CHECKPOINT between those batches.
Gail Shaw Microsoft Certified Master: SQL Server 2008, MVP SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Monday, June 04, 2012 5:00 PM
Points: 891,
Visits: 225
|
|
I have simple solution for you.
Copy 5 Million records to another dummy or staging table. Truncate the original table. And then copy 5 Million rows from Dummy table to original table.
If you do not have partitions created on table this is the fastest way.
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 10:58 AM
Points: 6,655,
Visits: 5,678
|
|
parthi-1705 (3/17/2010) I am having a 30 million records i need to delete 25 million old records with minimum log how it can be done there will be continues users accessing the table
Understand that minimum logging is different than "no" logging. You might want to change the Recovery mode to Bulk-Logged instead of Simple (unless the db is already set to Simple) before doing your delete. This way, if you need to recover, you'll still have a transaction log to recover from.
In Simple mode, checkpoints happen quite regularly and automatically. Usually, you'll hear people say "the transaction log truncates all transactions as soon as they are commited." It's not quite a true statement, but it does mean that transactions are unrecoverable almost instantaneously. The logging that occurs is only for the SQL Server engine, not for the DBA.
Per BOL: If the database is using the simple recovery model, an automatic checkpoint is generated whenever the number of log records reaches the lesser of these two values:
The log becomes 70 percent full.
The number of log records reaches the number the Database Engine estimates it can process during the time specified in the recovery interval option.
Brandie Tarvin, MCITP Database Administrator, MCDBA, MCSA
Webpage: http://www.BrandieTarvin.net LiveJournal Blog: http://brandietarvin.livejournal.com/ On LinkedIn!, Google+, and Twitter.
Freelance Writer: Shadowrun Latchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Yesterday @ 7:18 PM
Points: 10,989,
Visits: 10,532
|
|
Brandie Tarvin (3/17/2010) Understand that minimum logging is different than "no" logging. You might want to change the Recovery mode to Bulk-Logged instead of Simple (unless the db is already set to Simple) before doing your delete. This way, if you need to recover, you'll still have a transaction log to recover from. Deletes are always fully logged (truncate table excepted, which is always 'minimally logged' - sort of) regardless of the recovery model. Changing from simple recovery also changes nothing until a full backup is taken to establish a base for a future restore. The log stays in auto-truncate mode until the first full backup after a change from simple recovery.
Paul White SQL Server MVP SQLblog.com @SQL_Kiwi
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Yesterday @ 7:18 PM
Points: 10,989,
Visits: 10,532
|
|
vidya_pande (3/17/2010)
I have simple solution for you. Copy 5 Million records to another dummy or staging table. Truncate the original table. And then copy 5 Million rows from Dummy table to original table. If you do not have partitions created on table this is the fastest way.  Simple, yes. But not always practical on a production system. Also, remember that foreign key constraints will need to be dropped, indexes re-created etc etc etc Good idea, though.
Paul White SQL Server MVP SQLblog.com @SQL_Kiwi
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Wednesday, April 24, 2013 8:54 AM
Points: 45,
Visits: 571
|
|
vidya_pande (3/17/2010)
I have simple solution for you. Copy 5 Million records to another dummy or staging table. Truncate the original table. And then copy 5 Million rows from Dummy table to original table. If you do not have partitions created on table this is the fastest way. 
I had originally thought to do that since the table I had wasn't referenced by foreign keys. But its a replicated database, so no truncations allowed.
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Yesterday @ 7:18 PM
Points: 10,989,
Visits: 10,532
|
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Saturday, November 03, 2012 8:04 PM
Points: 37,
Visits: 123
|
|
Hi there,
I used a script to changed around 60 cust-test DBs from Full to simple recovery model as they were not needed to be in Full recovery mode etc
I did the change on Fri and today is Monday..I was expecting the see lot of space freed up on the drive where files are stored, by this as thinking it will run checkpoint etc....but below reasons tells me it wont happen straight away: ================ If the database is using the simple recovery model, an automatic checkpoint is generated whenever the number of log records reaches the lesser of these two values:
The log becomes 70 percent full.
The number of log records reaches the number the Database Engine estimates it can process during the time specified in the recovery interval option. =================
Some of these DBs have never been backed up but were in Full recovery model. So does this change anything? or is it a simple matter of watining?
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 2:00 PM
Points: 1,076,
Visits: 1,914
|
|
hp_dba_uk (9/24/2012) Hi there,
I used a script to changed around 60 cust-test DBs from Full to simple recovery model as they were not needed to be in Full recovery mode etc
I did the change on Fri and today is Monday..I was expecting the see lot of space freed up on the drive where files are stored, by this as thinking it will run checkpoint etc....but below reasons tells me it wont happen straight away: ================ If the database is using the simple recovery model, an automatic checkpoint is generated whenever the number of log records reaches the lesser of these two values:
The log becomes 70 percent full.
The number of log records reaches the number the Database Engine estimates it can process during the time specified in the recovery interval option. =================
Some of these DBs have never been backed up but were in Full recovery model. So does this change anything? or is it a simple matter of watining?
Are you waiting for the space to be available to OS? If yes, that won't happen automatically. Changing the recovery model to SIMPLE does break the log chain & allows the transaction log to be truncated on every check point. However, truncatation of the transaction log means making the inactive VLFs inside the transaction log file as reusable & nothing else.
In case you want the freed space returned to OS itself, you need to shrink the transaction log file.
Note: If you know that after few days the transaction log file is going to be of the same size again (after shrinking), there is no point in shrinking it.
- Divine Flame
|
|
|
|