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
»
Article Discussions
»
Article Discussions by Author
»
Discuss content posted by Sergiy
»
Best Practice
59 posts, Page 6 of 6
««
«
2
3
4
5
6
Best Practice
Rate Topic
Display Mode
Topic Options
Author
Message
Christian Buettner-167247
Christian Buettner-167247
Posted Monday, September 08, 2008 12:02 AM
SSCrazy
Group: General Forum Members
Last Login: Yesterday @ 6:12 AM
Points: 2,526,
Visits: 3,620
This is really useful information, thanks guys!
Best Regards,
Chris Büttner
Post #565224
Carlton Leach
Carlton Leach
Posted Monday, September 08, 2008 3:35 PM
SSC Eights!
Group: General Forum Members
Last Login: Monday, May 20, 2013 6:52 AM
Points: 863,
Visits: 1,022
I looked at this as more of a which one performs better question rather than the nature of the operation hence I chose 1.
I guess the absence of a transactin in the first statement has pulled the wool over everyones eyes!
Very good question this one, tip top!
Post #565803
Carlton Leach
Carlton Leach
Posted Monday, September 08, 2008 6:53 PM
SSC Eights!
Group: General Forum Members
Last Login: Monday, May 20, 2013 6:52 AM
Points: 863,
Visits: 1,022
Very well put on the tree falling in the woods comment, in my experience triggers appear to go by rows affected but also by statements in the execution i.e. if it reads the word "UPDATE" in a piece of code and there is an ON Update trigger on that table...f***en Bang.
Post #565846
Lynn Pettis
Lynn Pettis
Posted Monday, September 08, 2008 7:03 PM
SSC-Insane
Group: General Forum Members
Last Login: Today @ 7:54 AM
Points: 21,625,
Visits: 27,470
Sergiy (9/7/2008)
icocks (9/5/2008)
A further thing to bear in mind - if there's an Insert trigger on the table, then it will be fired in response to option 2, but not option 1. Depending on what it does (& how smart you've been in limiting the processing for a zero row insert) then there may be a further performance hit and/or lock escalation to take into account. Of course you may have good reasons for wanting it to fire for even an unsuccessful insert attempt.
In general I prefer to anti-join the value list back to the insert table since that's much more easily expandable for multi-row inserts & compound keys.
My opinion is that there's rarely a truly right or wrong answer to this kind of question - the real skill lies in understanding the strengths & weaknesses of each approach & then choosing the appropriate option for the system it's being applied to.
Look on what you are choosing from:
1. A solution which may cause errors in production environment but easy on resources;
2. A solution which is error safe but potentially causes some overhead.
Which one wold you choose for your car?
Are those airbags an overhead?
Have you ever been in a situation when you really needed it?
Have any of you friends?
So when you choose a car - will you prefer the one without airbags?
Why?
Having walked away from an accident where I slammed my car into a ditch at 70 MPH, I want both seat belts (lap and shoulder) and air bags.
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 #565850
Anipaul
Anipaul
Posted Monday, September 08, 2008 11:10 PM
SSCarpal Tunnel
Group: General Forum Members
Last Login: 2 days ago @ 1:35 AM
Points: 4,789,
Visits: 1,336
Excellent question...
Post #565903
Preet_S
Preet_S
Posted Wednesday, September 10, 2008 6:51 AM
SSC Veteran
Group: General Forum Members
Last Login: Wednesday, May 01, 2013 5:15 AM
Points: 236,
Visits: 235
Ric Sierra (9/4/2008)
I'm not completly agree with the answer, because depends of the context:
If you are looking for the best execution plan the answer is #1
If you are looking for less deadlock the answer is #2
But if the target is INSERT a new record, both solutions works.
Isn't 'correctness' favoured first ?
i.e. you look to ensure that you achieve what was intended and then look to optimise (secondary). The correct thing in my mind would be option 2 as explained in the solution.
Let the definition of 'correctness' commence...
Post #566829
Anam Verma
Anam Verma
Posted Monday, October 20, 2008 6:35 PM
Mr or Mrs. 500
Group: General Forum Members
Last Login: 2 days ago @ 11:53 PM
Points: 524,
Visits: 1,181
good question followed by interesting discussion. :)
Post #588897
shamas-805328
shamas-805328
Posted Friday, October 24, 2008 3:19 AM
SSC Rookie
Group: General Forum Members
Last Login: Friday, October 24, 2008 3:24 AM
Points: 37,
Visits: 50
Good Question But not clear in the sense of Blocking the record.
Post #591046
kapil_kk
kapil_kk
Posted Thursday, December 13, 2012 6:48 AM
Ten Centuries
Group: General Forum Members
Last Login: Sunday, May 19, 2013 11:16 PM
Points: 1,061,
Visits: 1,151
good question
+3
Post #1396161
« Prev Topic
|
Next Topic »
59 posts, Page 6 of 6
««
«
2
3
4
5
6
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.