Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 1234»»»

Avoiding Logging Expand / Collapse
Author
Message
Posted Monday, March 7, 2011 9:17 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Yesterday @ 5:56 PM
Points: 33,202, Visits: 15,348
Comments posted to this topic are about the item Avoiding Logging






Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1074590
Posted Monday, March 7, 2011 9:32 PM


Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Sunday, July 6, 2014 8:03 PM
Points: 687, Visits: 1,110
Great editorial, Steve. You can't make solid, durable furniture (or databases) without logging!
Post #1074594
Posted Monday, March 7, 2011 10:27 PM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Wednesday, May 7, 2014 7:16 AM
Points: 650, Visits: 1,265
HA!

If it wasn't for the Murphy's of the world, we wouldn't need a tlog in the first place. But here we are, now everyone gets to become very familiar with recoverability strategies. You are welcome for the contribution.

I think some folks think that if the db is in the Simple recovery model, then the tlog is not used. Wrong. The .ldf is still locked by the OS indicating that it is still in use. And deleting the .ldf with the services stopped is, uh, bad. Why? Because SQL needs and uses the tlog, even on db's which are in Simple. It just doesn't use the tlog LONG TERM. Well, this is relative; when the next checkpoint occurs and whatnot.

I'm changing my name to Jones. Just trying to keep up with Steve.

Jim


Jim Murphy
http://www.sqlwatchmen.com
@SQLMurph
Post #1074603
Posted Tuesday, March 8, 2011 1:38 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, August 11, 2014 8:42 PM
Points: 5, Visits: 185
Have to agree Steve. Here in Christchurch, thanks to the earthquake, I'm becoming intimately familiar with the other side of disaster recovery. Fortunately without too much drama, and very thankful it's so robust!

Tim Elley
Christchurch, New Zealand



Post #1074635
Posted Tuesday, March 8, 2011 2:02 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 10:46 AM
Points: 13,622, Visits: 10,513
In the somewhat special case of ETL, I'd sometimes like to turn of logging.
If a data load fails, the destination table can be truncated and the load can start over again, so you would not have to worry about inconsistency.
I'm only talking about the import layer here (the E of ETL). If updates are performed on datasets in the database, I would very much like logging, as I would like to go back to a previous state if necessary. But for imports, nah, I don't need logging




How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1074641
Posted Tuesday, March 8, 2011 6:26 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Friday, June 27, 2014 12:43 PM
Points: 15,444, Visits: 9,596
Koen Verbeeck (3/8/2011)
In the somewhat special case of ETL, I'd sometimes like to turn of logging.
If a data load fails, the destination table can be truncated and the load can start over again, so you would not have to worry about inconsistency.
I'm only talking about the import layer here (the E of ETL). If updates are performed on datasets in the database, I would very much like logging, as I would like to go back to a previous state if necessary. But for imports, nah, I don't need logging


Would the Bulk Logged recovery model accomplish what you want on that?

You can also have a staging database, where you bulk import, et al, kept in Simple recovery, and just leave it out of the backup and maintenance plans. The log will grow to accommodate your imports, but it's simpler and less critical than a "real" database. If needed/wanted, keep that one on a cheap RAID 0 array. If it crashes and burns, replace the disks and re-run the create script from source control, and don't worry about recovery. Just make sure it's set up so that you don't lose anything that matters if you lose the whole database.


- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread

"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Post #1074739
Posted Tuesday, March 8, 2011 6:41 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 7:36 AM
Points: 23,294, Visits: 32,029
Actually, it is possible to do this in Oracle. I had a nice discussion about it with one of the Oracle gurus where I work. He would never recommend using this capability on an online database, but would use it in a tightly controlled batch process where online activity is prevented from accessing the database. He would also take precautions, including ensuring that there was a backup prior to and after the batch process.

Perhaps it is because this can be done in Oracle that people think SQL Server has a similar capability.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1074749
Posted Tuesday, March 8, 2011 6:47 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 10:46 AM
Points: 13,622, Visits: 10,513
GSquared (3/8/2011)
Koen Verbeeck (3/8/2011)
In the somewhat special case of ETL, I'd sometimes like to turn of logging.
If a data load fails, the destination table can be truncated and the load can start over again, so you would not have to worry about inconsistency.
I'm only talking about the import layer here (the E of ETL). If updates are performed on datasets in the database, I would very much like logging, as I would like to go back to a previous state if necessary. But for imports, nah, I don't need logging


Would the Bulk Logged recovery model accomplish what you want on that?

You can also have a staging database, where you bulk import, et al, kept in Simple recovery, and just leave it out of the backup and maintenance plans. The log will grow to accommodate your imports, but it's simpler and less critical than a "real" database. If needed/wanted, keep that one on a cheap RAID 0 array. If it crashes and burns, replace the disks and re-run the create script from source control, and don't worry about recovery. Just make sure it's set up so that you don't lose anything that matters if you lose the whole database.


Bulk Logged recovery model certainly is an option. So is the Simple recovery model.
My point is that when the ETL tightly controls the batch process and the destination database is only used as a "dump" for the data (aka volatile staging area, where destination tables are cleared before the import process), that all the logging is just extra overhead interfering with (BULK) INSERT performance. For the same reason it is also recommended not to have constraints (be it foreign keys or check constraints) and to minimize indexing (you can even drop the indexes and recreate them after the import process).

If it is a non-volatile staging area, then a backup before the import process is sufficant, as Lynn already mentioned.

But maybe I'm preaching to the choir




How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1074753
Posted Tuesday, March 8, 2011 7:26 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, August 25, 2014 3:46 PM
Points: 22, Visits: 45
Earlier version of SQL Server did support No Logging.

Bulk Copy was the reason. In those days BCP was non-transacted resulting in higher performance. In order for it to be non-transactional you had to set your recovery mode to simple (They really didn't have Recovery Mode back then, but that is the closest thing they have today). In the oldest versions (4.21 say) it didn't even update indexes when you did a bulk copy of this nature using the BCP.EXE command.

After doing a BCP you had to update statistics, rebuild indexes and backup your database. Basically, it was the fastest way to get staging data into SQL Server. It was a pain. IT WAS FAST!

As you say, this mode is not supported with SQL Server today, but the idea is not a fantasy...it used to exist. Why doesn't it exist today; I don't know or care. Frankly, with todays hardware I see reasonable performance with logging, so why turn it off.

A second method of not using the transaction log was

SELECT ... INTO #SomeTempTable FROM ...

This query did not use the transaction log in any of the databases including TempDB. There were problems with this technique fixed in version 7 where the SYSOBJECTS table in Tempdb was locked until the select statement completed (A potential disaster). So the technique was not often used.

In SQL Server 2005 an dlater this technique still performs faster than creating a temp table and inserting data into it with a select statement. However, I know there is logging involved because I use that ability in transactions for SAVE POINTS and transactions. The level of logging is unknown to me nor why there is increased performance. However, I do have performance history demonstrating the technique is still valid.

There were lots of things we did, or had to do, in the old days that are no longer relevant, or methods have changed. That doesn't mean they were never true. For example, MS Best practices used to teach us to use a non-squential column with low data distribution for a clustered index. It was on their SQL Server tests for certification. Today the best practice is the exact opposite. MS recommends a sequential value as a clustered index, even if it is not the primary key.

Thanks for reminding me how old I am, and how long I have been working with SQL Server.

Ben
Post #1074781
Posted Tuesday, March 8, 2011 7:44 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 10:46 AM
Points: 13,622, Visits: 10,513
taylor_benjamin (3/8/2011)

Thanks for reminding me how old I am, and how long I have been working with SQL Server.


There was a 4.21 version???




How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1074806
« Prev Topic | Next Topic »

Add to briefcase 1234»»»

Permissions Expand / Collapse