Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQLServerCentral.com
»
Editorials
»
Avoiding Logging
39 posts, Page 1 of 4
1
2
3
4
»
»»
Avoiding Logging
Rate Topic
Display Mode
Topic Options
Author
Message
Steve Jones - SSC Editor
Steve Jones - SSC Editor
Posted Monday, March 07, 2011 9:17 PM
SSC-Dedicated
Group: Administrators
Last Login: 2 days ago @ 1:47 PM
Points: 31,406,
Visits: 13,722
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
Jim McLeod
Jim McLeod
Posted Monday, March 07, 2011 9:32 PM
Say Hey Kid
Group: General Forum Members
Last Login: Today @ 4:40 AM
Points: 687,
Visits: 1,074
Great editorial, Steve. You can't make solid, durable furniture (or databases) without logging!
Post #1074594
Jim Murphy
Jim Murphy
Posted Monday, March 07, 2011 10:27 PM
SSChasing Mays
Group: General Forum Members
Last Login: Monday, May 13, 2013 12:49 PM
Points: 632,
Visits: 1,224
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
Jack
Jack
Posted Tuesday, March 08, 2011 1:38 AM
Forum Newbie
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 3:43 PM
Points: 5,
Visits: 152
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
Koen Verbeeck
Koen Verbeeck
Posted Tuesday, March 08, 2011 2:02 AM
SSCrazy Eights
Group: General Forum Members
Last Login: Today @ 1:01 PM
Points: 9,367,
Visits: 6,463
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
GSquared
GSquared
Posted Tuesday, March 08, 2011 6:26 AM
SSCoach
Group: General Forum Members
Last Login: Monday, May 06, 2013 1:09 PM
Points: 15,439,
Visits: 9,569
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
Lynn Pettis
Lynn Pettis
Posted Tuesday, March 08, 2011 6:41 AM
SSC-Insane
Group: General Forum Members
Last Login: Today @ 5:45 PM
Points: 21,589,
Visits: 27,390
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
Koen Verbeeck
Koen Verbeeck
Posted Tuesday, March 08, 2011 6:47 AM
SSCrazy Eights
Group: General Forum Members
Last Login: Today @ 1:01 PM
Points: 9,367,
Visits: 6,463
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
taylor_benjamin
taylor_benjamin
Posted Tuesday, March 08, 2011 7:26 AM
Grasshopper
Group: General Forum Members
Last Login: Sunday, May 12, 2013 9:12 PM
Points: 22,
Visits: 32
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
Koen Verbeeck
Koen Verbeeck
Posted Tuesday, March 08, 2011 7:44 AM
SSCrazy Eights
Group: General Forum Members
Last Login: Today @ 1:01 PM
Points: 9,367,
Visits: 6,463
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 »
39 posts, Page 1 of 4
1
2
3
4
»
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.