Archive

Archive for the ‘Link’ Category

BI SQL # 276 : SQL Server DBA Scripts : Find all DB IO with Rank

April 16, 2014 Leave a comment

Hi Folks,

In this article we are going to cover How to Find all DB IO with Rank.

In this post we are going to discuss following points:

  • Problem Statement of SQL Script:
  • Description of SQL Script:
  • SQL Script Output Column
  • SQL Script Code
  • User Level to execute

Problem Statement of SQL Script:

How to Find all DB IO with Rank ?

Description of SQL Script:

This script will find all DB IO with Rank.

SQL Script Output Column

image

SQL Script Code

WITH DBIO
AS (
    SELECT DB_NAME(IVFS.database_id) AS db
        ,CASE 
            WHEN MF.type = 1
                THEN 'log'
            ELSE 'data'
            END AS file_type
        ,SUM(IVFS.num_of_bytes_read + IVFS.
            num_of_bytes_written) AS IO
        ,SUM(IVFS.io_stall) AS io_stall
    FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS IVFS
    INNER JOIN sys.master_files AS MF ON IVFS.database_id = MF.
        database_id
        AND IVFS.file_id = MF.file_id
    GROUP BY DB_NAME(IVFS.database_id)
        ,MF.[type]
    )
SELECT db
    ,file_type
    ,CAST(1. * IO / (1024 * 1024) AS DECIMAL(12, 2)) AS 
    io_mb
    ,CAST(io_stall / 1000. AS DECIMAL(12, 2)) AS io_stall_s
    ,CAST(100. * io_stall / SUM(io_stall) OVER () AS 
        DECIMAL(10, 2)) AS io_stall_pct
    ,ROW_NUMBER() OVER (
        ORDER BY io_stall DESC
        ) AS rn --into DBIOStallWithRank
FROM DBIO
ORDER BY io_stall DESC

User Level to execute

    300

    Hope you will like How to Find all DB IO with Rank.

    If you really like reading my blog and understood at least few thing then please don’t forget to subscribe my blog.

If you want daily link and analysis or interesting link go to following website which will give @ your inbox please subscribe our following link resource blog :

Link Resource Website

For More information related to BI World visit my Mentalist Blog

SQL Server Mentalist >> SQL Learning Blog

Business Intelligence Mentalist >> BI World

Infographic Mentalist >> Image worth explaining thousand Words

Microsoft Mentalist >> MVC,ASP.NET, WCF & LinQ

DBA Mentalist >>Advance SQL Server Blog

Microsoft BI Mentalist >> MS BI Development Update

Connect With me on

| FaceBook |Twitter | linkedIn| Google+ | WordPress | RSS |

Follow

Get every new post delivered to your Inbox.

Join 1,120 other followers

%d bloggers like this: