|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 1:49 PM
Points: 5,122,
Visits: 20,362
|
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: 2 days ago @ 10:29 PM
Points: 2,178,
Visits: 3,599
|
|
Thanks, nice question
Mohammed Moinudheen
|
|
|
|
|
UDP Broadcaster
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 3:15 AM
Points: 1,479,
Visits: 1,943
|
|
There are several problems with this question. One being that you cant declare @Start 2 times.
The other being that the answer is wrong. They both perform equally. I have executed the query as is (though with the @Start thing dealt with). With the 2 queries in the opposit order and one at a time. And the time is always roughly 100ms result (give or take 10ms).
I get the same execution plan (2005) for both queries. So im hoping that someone with more knowledge then me can enlighten us.
The above ramblings can be ignored. Rewriting it i had missed that there are 2! selects. Running the code from the link was "better". And had the effect that was being pointed out.
/T
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Thursday, September 20, 2012 7:53 AM
Points: 443,
Visits: 69
|
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 1:58 AM
Points: 2,499,
Visits: 2,199
|
|
Thanks Ron - I learnt again today
------------------------------- Posting Data Etiquette - Jeff Moden Smart way to ask a question
There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan I would never join a club that would allow me as a member - Groucho Marx
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Today @ 2:07 AM
Points: 1,994,
Visits: 1,857
|
|
tommyh (10/3/2011) There are several problems with this question. One being that you cant declare @Start 2 times.
The other being that the answer is wrong. They both perform equally. I have executed the query as is (though with the @Start thing dealt with). With the 2 queries in the opposit order and one at a time. And the time is always roughly 100ms result (give or take 10ms).
I get the same execution plan (2005) for both queries. So im hoping that someone with more knowledge then me can enlighten us.
/T You should execute the two batch separately, so, you can declare @Start twice. But, I agree with you: the answere is wrong and hardly to establish which perform better.
|
|
|
|
|
UDP Broadcaster
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 3:15 AM
Points: 1,479,
Visits: 1,943
|
|
Carlo Romagnano (10/3/2011)
tommyh (10/3/2011) There are several problems with this question. One being that you cant declare @Start 2 times.
The other being that the answer is wrong. They both perform equally. I have executed the query as is (though with the @Start thing dealt with). With the 2 queries in the opposit order and one at a time. And the time is always roughly 100ms result (give or take 10ms).
I get the same execution plan (2005) for both queries. So im hoping that someone with more knowledge then me can enlighten us.
/TYou should execute the two batch separately, so, you can declare @Start twice. But, I agree with you: the answere is wrong and hardly to establish which perform better.
I did do that too... but i also wanted to run the code "as is" incase it was something that was dependent on them being run both at the same time.
/T
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Thursday, June 13, 2013 9:46 AM
Points: 3,157,
Visits: 4,341
|
|
Interesting question, Ron. Thanks
Something to bear in mind: There are numerous factors that influence the choice between table variables and/or temp tables, inter alia: > Data set size (number of columns and rows) - larger datasets work better with temp tables (mainly because these can be indexed); > Availalbe memory vs available drive space (file swapping etc); > IO's; > Persistence (using the data set in other stored procedures) > UDF - one can only use table variables in UDF's
____________________________________________ Space, the final frontier? not any more... All limits henceforth are self-imposed. “libera tute vulgaris ex”
|
|
|
|
|
UDP Broadcaster
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 3:15 AM
Points: 1,479,
Visits: 1,943
|
|
stewartc-708166 (10/3/2011) Interesting question, Ron. Thanks
Something to bear in mind: There are numerous factors that influence the choice between table variables and/or temp tables, inter alia: > Data set size (number of columns and rows) - larger datasets work better with temp tables (mainly because these can be indexed); > Availalbe memory vs available drive space (file swapping etc); > IO's; > Persistence (using the data set in other stored procedures) > UDF - one can only use table variables in UDF's
The first 2 points are "wrongish". http://sqlinthewild.co.za/index.php/2010/10/12/a-trio-of-table-variables/
/T
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, January 24, 2013 9:59 PM
Points: 1,354,
Visits: 1,299
|
|
tommyh (10/3/2011) There are several problems with this question. One being that you cant declare @Start 2 times.
The other being that the answer is wrong. They both perform equally. I have executed the query as is (though with the @Start thing dealt with). With the 2 queries in the opposit order and one at a time. And the time is always roughly 100ms result (give or take 10ms).
I get the same execution plan (2005) for both queries. So im hoping that someone with more knowledge then me can enlighten us.
/T I agree that they would both perform equally and the answer is wrong. The referenced link was regarding stored procedures and the example code in the QOTD was not a stored procedure. Suppose that makes a difference because it would need to be recompiled in a stored procedure but if you're running it for the first time as a non-stored procedure query, they both need to be parsed and an execution plan created anyway.
|
|
|
|