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
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 deleting rows affect transaction log?

Author  Topic 

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2011-11-07 : 22:05:21
Hi.
I have a job that deletes rows from a table every 15minutes.
The amount is not great, it is 20-30 rows at every job execution.
What i want to ask is if this will raise the transaction log a lot because even if i am not deleting many rows , i still delete every 15 minutes so at the end of the day i may have 30x4x24 =2880 rows a day.
I don't want to log any row but i cannot truncate because i am keeping some rows in the table.
Any advise?
Thanks.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-11-07 : 22:37:02
We have that many changes (2880) in just a few seconds, and our tlog is fine. We backup our tlog every 15 minutes. What recovery model are you using? And if it's not SIMPLE, then how often are you backing up your tlog?

Your transaction has to be logged no matter what recovery model you are using. There isn't a way around this as SQL Server has to ensure data consistency.

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

Subscribe to my blog
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2011-11-08 : 00:23:38
Hi.Full recovery model.The backup is the database on a zip drive daily.I'm not in charge of this so i don't know if the tlog is backed up but i'm sure the main database is backed up every day.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-11-08 : 00:33:04
It makes a huge difference to find out if the transaction log is backup up and how often. If you aren't backing it up, then you are going to run into a problem.

Please check with your DBA or whoever sysadmins this server.

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

Subscribe to my blog
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2011-11-08 : 00:42:40
Will do.Can you tell me what problems i may run in the long run,or point me to a link?
Thanks.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-11-08 : 00:44:57
Well if you aren't backing up the transaction log and the recovery model is set to full, the file is going to continually grow until it either hits its maximum size or until you run out of space on the drive. So there'll be downtime here either way.

Make sure you find out the answer and get it corrected if needed. If it isn't being backed up, your options are to start backing it up regularly, like every 15 minutes, or change your recovery model to SIMPLE. Please be aware of what SIMPLE and FULL means before making a switch though as it affects your point-in-time recovery options.

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

Subscribe to my blog
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2011-11-08 : 01:20:47
Thanks.
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-11-08 : 04:29:27
Maybe this - [url]http://www.sqlservercentral.com/articles/64582/[/url]

--
Gail Shaw
SQL Server MVP
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2011-11-08 : 18:37:31
Thanks.I asked and the main log is backed up too.Can rollback transactions be used in bulk model sufficiently?I am using almost every update sp with rollback transaction so i wouldn't like to have any problems.An up to 3 days data loss can be accepted.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-11-08 : 18:55:55
You can wrap it into a transaction.

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

Subscribe to my blog
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2011-11-08 : 19:17:49
Hmm.Sorry i didn't get the last comment(non native english language).I can use bulk model with transactions?Is that what you wrote?
Thanks.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-11-08 : 19:20:20
Oh sorry, I thought you were asking about BULK INSERT. I guess you are asking about the BULK_LOGGED recovery model. Yes you can rollback transactions using that recovery model. You can rollback transactions even with SIMPLE recovery model.

The recovery model just determines what happens after the transaction completes (commit or rollback), it has nothing to do with what happens during the transaction.

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

Subscribe to my blog
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2011-11-08 : 21:11:37
Ok,got it.
Thanks.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2011-11-09 : 03:13:59
"up to 3 days data loss can be accepted."

Sounds like SIMPLE recovery model will do for you then, with daily backups.

We use FULL recovery model to:

Be able to restore with the minimum data loss

Be able to restore to point-in-time (e.g. to investigate possible fraud, or some other "how did this happen" type question)

Have additional safeguard against database corruption. A corruption that went unnoticed for a while would quite likely be cured by restoring the last "clean" full backup, and all Log backups since.

To be able to use Log shipping to a separate disaster-recovery server in case of total loss of the primary server.

If you don't need any of those benefits then SIMPLE should be sufficient for you.
Go to Top of Page

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2011-11-09 : 20:23:29
It's not my call Kristen.I would like all these options but it's not up to me.
Thanks.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2011-11-10 : 03:36:10
Well currently you have all those options as you are using FULL Recovery Model. However, for an application that can tolerate a 3-day data loss you could use SIMPLE.

You are having to work on issues such as minimising Logs, because you are using FULL, which you would not need to spend time on using SIMPLE

As others have said, ask your Admin folk how often they back up the Log file. If its "never" you will get Disk Full at some point! if its once-a-day then the LDF file is probably huge, in comparison to what it needs to be, and "every 15 minutes" is, in my experience, the most commonly recommended interval for log backup.

The LDF Transaction Log File will grow to hold the largest transaction set that it has ever seen. If it is backed up once a day that will be the size of all the transaction on the "busiest" day. If the log is backed up every 15 minutes then the LDF only needs to be large enough to hold the "busiest" 15 minutes.

The total size of all the backup files, taken every 15 minutes, will be the same as the single once-a-day log backup file (well, there will be some "overhead" in each file), so there is rarely any good reason for not doing backing up the log "frequently"
Go to Top of Page
   

- Advertisement -