|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Monday, April 08, 2013 7:19 AM
Points: 25,
Visits: 165
|
|
| I think the Answer is ( 0 ) Bz the field QOTDID don't exist, there no Update.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, May 09, 2013 10:23 AM
Points: 1,263,
Visits: 234
|
|
An unusual situation occurred for me. The first time I ran the SELECT statement the plan was a Clustered Index Scan. Subsequent runs were the expected NC Index Seek & Key Lookup. It took me a moment to realize the cause - it was due to having the following database settings set: Auto Create Statistics - On Auto Update Statistics - On Auto Update Statistics Asynchronously - On
Testing with the various settings yields these results: If you do not Auto Create stats you only get a clustered index scan. If you Auto Create but do not Auto Update you also only get a clustered index scan. If you Auto Update stats (synchronously) you get the results in the answer (NC Index Seek & Key Lookup). And finally if you Auto Update Statistics Asynchronously the first run is clustered index scan with subsequent runs NC Index Seek & Key Lookup.
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Friday, February 04, 2011 7:20 AM
Points: 977,
Visits: 1,499
|
|
Got lucky and got the points, but mainly I learnt something.
Good QotD.
Thanks,
Tom Garth Vertical Solutions
"There are three kinds of men. The one that learns by reading. The few who learn by observation. The rest of them have to pee on the electric fence for themselves." -- Will Rogers
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Monday, November 01, 2010 7:50 PM
Points: 83,
Visits: 59
|
|
DAMN -- got it wrong! Know why? Because I over-thought the answer: I though that since the counter (@i) started at 0 and incremented to 499, there would never be a record with QOTDID = 500.
Unfortunately, I forgot that the QOTDID field started at 1, so the very last record gets an id of 500.
Damn, Sam!
Thanks, - Joseph Marsh
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 11:21 AM
Points: 2,163,
Visits: 2,148
|
|
| Great question, gets you to actually thinking about what SQL Server is doing in the background.
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: 2 days ago @ 12:22 PM
Points: 10,571,
Visits: 11,871
|
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: 2 days ago @ 3:21 AM
Points: 1,843,
Visits: 971
|
|
Hi,I checked this query by using estimated execution plan(graphical). there is one inner join between one index seek on email address and another index seek on Qotdid .but i done wrong.
Malleswarareddy I.T.Analyst MCITP(70-451)
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: 2 days ago @ 2:53 AM
Points: 1,526,
Visits: 359
|
|
CirquedeSQLeil (5/5/2010) This is a good question. Thanks. One other method one can use to demonstrate this is by evaluating the actual execution plan.
yep.. I also used the execution plan to get the answer
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: 2 days ago @ 2:53 AM
Points: 1,526,
Visits: 359
|
|
| thanks... got to learn something new today... wasn't aware of Profile stats
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: 2 days ago @ 3:37 AM
Points: 3,691,
Visits: 957
|
|
Hmmm, I get "Clustered Index Scan" as both PhysicalOp and LogicalOp in SQL 2008 with Auto Statistics "false". With Auto Statistics "true" I get one inner join. I have to check why Auto Statistics was "false" on that test database...
Lars Broberg Elbe-Data AB
|
|
|
|