Scroll Bar


you can participate with latest Interview Questions here. Use this mail ID (bhanudba15@gmail.com) to send Your Questions.

DMV's


1. What is ITW in SQL 2000 and What are DMVs?
ITW is Index Tuning Wizard and was available in SQL 2000 days. We rewamped it as DTA (Database Tuning Wizard) in SQL Server 2005 which was far more powerful than the SQL 2000 ITW counterpart. Now to get into the second part, Dynamic Management Views (DMV) provide greater transparency and insight into the database and a powerful infrastructure for proactive monitoring of database health and performance to make managing data more flexible and secure.

2. do we need to run DMV on prod server or we can run on the restored DB also
We need to understand one fundamental thing here, DMV's are like pseudo views / tables that are exposing the in-memory structures of SQL Server. These are useful to diagnoze any potential problems that might occur in that system. Some of these views are transient and some are cummulative and some get fulshed from time-to-time. Typical examples in these categories would incude Locks data is transient and changes every micro-second while data like the Index usage (seeks, scans etc) are cummulative and data like the query cache can get flushed if there is memory pressure from any other side. Having said all this, these data are NOT like metadata (e.g. sys.tables) which can be restored on another DB and analyzed. There is a way in SQL Server 2008 using Data Collector that we can do this and check the architecture here:http://msdn.microsoft.com/en-us/library/bb677355.aspx

3. all these DMV are part of SQL 2005
DMV's were very much intrduced as concepts inside SQL Server 2005 itself. AFAIK, there were close to 80+ DMV's with SQL Server 2005 RTM build. We increased this set to ~136 with this new version of SQL Server 2008.

4. How to get a list of all DMVs available for us to query upon....?
Here is a simple query that will help you answer this part:        
SELECT * FROM sys.all_objects      
   WHERE [name] LIKE '%dm_%'   
                AND [type] IN ('V', 'TF', 'IF')  
ORDER BY [name]

With SQL 2008 we introduced a number of DMV's around auditing, Extended Events, CDC, Filestreams etc.

5. what will calculeted by awe_allocated_kb
This value shows the overall amount of memory that is allocated through the AWE mechanism on the 32-bit version of SQL Server. Or, this value shows the overall amount of memory that locked pages consume on the 64-bit version of the product. This value comes from the sys.dm_os_memory_clerks DMV and the documentation for the same is at:http://msdn.microsoft.com/en-us/library/ms175019.aspx.

7. What permission does a user need to access the DMV's
There are two types of dynamic management views and functions:     
Server-scoped dynamic management views and functions (e.g OS, IO, Threads, tasks etc). These require VIEW SERVER          STATE permission on the server.   
Database-scoped dynamic management views and functions (e.g Index, Tables, partition, file etc). These require VIEW DATABASE STATE permission on the database.

8. Which DMV give me query plan or I will use old method to find query plan?
Here is a query that you can run to get the Total Elapsed time of queries and the number of times those queries were hit. It also give's you the query and the plan used for each of those.

select qs.execution_count   
     , qs.total_elapsed_time, qs.last_elapsed_time 
     , qs.min_elapsed_time, qs.max_elapsed_time 
     , substring(st.text, (qs.statement_start_offset/2)+1 
                        , ((case qs.statement_end_offset       
                              when -1 then datalength(st.text)  
                              else qs.statement_end_offset      
                           end - qs.statement_start_offset)/2) + 1) as statement_text       
      , qp.query_plan 
from sys.dm_exec_query_stats as qs      
cross apply sys.dm_exec_sql_text(qs.sql_handle) as st   
cross apply sys.dm_exec_query_plan (qs.plan_handle) as qp

9. How are DMV's and DMF's changing the memory consumptions of SQL Server? consider the dm_exec_* which store the results of the current workload.
I think this has come a number of times from various people I have interacted. As described before, DMV's are in-memory structures and are anyway's used by SQL Server internally. It is with SQL Server 2005 that we started exposing them in an official manner rather than doing bit-manipulations with some DBCC commands. Hence there is nothing to be worried about the load or memory consumptions. It is not as alarming as you think.

10. does there is support for DMVs in SQL 2000?
DMV's were introduced with SQL Server 2005 onwards. Though these numbers are increasing from version to version these cannot be got with SQL 2000 version. If you are still using SQL Server 2000 version I would strongly recommend you to move to SQL Server 2008 version :).

11. it seems to be very hard to remember DMV names, is there any way to get list of DMV's and its usage?
Fair enough and I dont think you are the only person finding it difficult :). With SQL Server 2005 I gone to BOL a number of times, but with SQL 2008 the intellisense takes away half the problem. But if you want to learn more on DMV's and start using them then I would recommend you to book mark this page on MSDN: http://msdn.microsoft.com/en-us/library/ms188754.aspx

 

No comments:

Post a Comment

DisableRC