SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Question of the Day for 07 May 2007


Question of the Day for 07 May 2007

Author
Message
Tao Klerks
Tao Klerks
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1559 Visits: 1249

The "Right" answer is apparently a little misleading here... According to BOL, there would be entries in the DMV, they would just have all counters set to 0.

http://msdn2.microsoft.com/en-us/library/ms188755.aspx

Effectively, this would mean that the DMV DOES tell you something - it gives you a list of all the indexes used since the database itself was last shut down or detached.

But then maybe it's just unclear in the BOL article, and the rows really are all removed every time the service is started. Does anyone know? (I don't have 2005 handy to test...)

Thanks,

Tao



http://poorsql.com for T-SQL formatting: free as in speech, free as in beer, free to run in SSMS or on your version control server - free however you want it.
Hugo Kornelis
Hugo Kornelis
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11442 Visits: 12007

Tao: BOL is indeed misleading. You can try it if you have a test server at your disposal - run some queries, check that various indexes used show up in sys.dm_db_index_usage_stats, restart the server and then query sys.dm_db_index_usage_stats again.

<nitpicking>

You don't really get "no" information. You'll at least get a list of column names <g>. And you'll get an overview of what indexes were used during system startup. On my test database, startup apparently involved one scan of sysendpts and one scan of sysobjvalues.

If the server has some huge startup procedures, querying sys.dm_db-index_usage_stats right after a server restart might even be useful...

</nitpicking>

Nitpicking aside, this is a great question. Many people still don't know about this view. And judging by the distribution of answers, many people don't know that it's fllushed on restart either.

Edit: One more nitpick - this view is not available on versions prior to SQL Server 2005.




Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
xcmuchip
xcmuchip
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 Visits: 4

I was torn between (A) and (D). I chose (A) because the question said that the user began using the server. My mistake was to assume the query "sys.dm_db_index_usage_stats DMV" was NOT the first thing the user did. I assumed that they had actually did other things before this query was ran.

Oh well.





TDuffy
TDuffy
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1478 Visits: 57
Counters set to 0 are still providing info on how the indexes are used. The correct answer is A. Perhaps these questions should educate rather than try to trick.



Mike C
Mike C
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2823 Visits: 1168
Tricky question - I got caught myself, assuming that counters set to zero are not "nothing".
Hugo Kornelis
Hugo Kornelis
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11442 Visits: 12007
TDuffy: See my previous reply to Tao. Query this view on a just recycled server, and you get (almost) nothing.


Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Steve Jones
Steve Jones
SSC Guru
SSC Guru (66K reputation)SSC Guru (66K reputation)SSC Guru (66K reputation)SSC Guru (66K reputation)SSC Guru (66K reputation)SSC Guru (66K reputation)SSC Guru (66K reputation)SSC Guru (66K reputation)

Group: Administrators
Points: 66232 Visits: 19120
Ah, it wasn't to trick you, but educate you that these are restart-restart counters. I think you could argue that they are set to zero, or nothing. It's just that you don't get any info if you query the view.

I'll reword the answer and explanation to say they're reset.

Plus if the answer is obvious and can be "guessed" then you might not bother to pay attention or look up the info.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Hugo Kornelis
Hugo Kornelis
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11442 Visits: 12007

Steve: Once more (and than I'll drop this). BOL is confusingly worded. The counters are *NOT* reset. You don't need to reword the question (but adding a bit to the explanation in the answer wouldn't hurt).

Cycle a server and query the view if you don't believe me.




Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Nakul Vachhrajani
Nakul Vachhrajani
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2330 Visits: 2145
Hello!

I am confused as well. Here's what I did (on a SQL 2008 box):
1. Ran the query mentioned
2. Restarted the services (both SQL Server Agent & SQL Server)
3. Re-ran the query once the server was back up - I got the results same as in step #1

Thanks & Regards,
Nakul Vachhrajani.
http://nakulvachhrajani.com
Be courteous. Drive responsibly.

Follow me on
Twitter: @sqltwins
Google Plus: +Nakul
Ken Wymore
Ken Wymore
SSCertifiable
SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)SSCertifiable (5.1K reputation)

Group: General Forum Members
Points: 5133 Visits: 2377
I answered this one incorrectly as well. I got stats back after restarting my SQL server. While there was little information, there was still something returned.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search