Sign In
Vijay
Translate This Page
Translate this page
Powered by
Microsoft® Translator
Options
Blog Home
Email Blog Author
Share this
RSS for posts
Atom
RSS for comments
Search
Advanced search options...
Search In:
Everything
Blogs
Forums
People
Groups
Places
Pages
Date range:
All Time
Last Year
Last 6 Months
Last 3 Months
Last Month
Last Week
Last Two Days
Tags
@@SERVERNAME
Features by Edition
GROUP ACCOUNT
RESOURCE DATABASE
Transaction Log
Archive
Archives
May 2009
(2)
April 2009
(2)
February 2009
(1)
January 2009
(2)
August 2008
(3)
September 2007
(2)
Query to list all the databases in the order of CPU usage
MSDN Blogs
>
Vijay
>
Query to list all the databases in the order of CPU usage
Query to list all the databases in the order of CPU usage
Vijay Korapadi
12 Jan 2009 9:01 AM
Comments
0
USE
master
SELECT
a
.
[value]
AS
[dbid]
,
ISNULL
(
DB_NAME
(
CONVERT
(
INT
,
a
.
[value]
)),
'Resource'
)
AS
[DB Name]
,
SUM
(
qs
.
[execution_count]
)
AS
[Counts]
,
SUM
(
qs
.
[total_worker_time]
)
/
1000
AS
[Total Worker Time (mSecs)]
,
SUM
(
qs
.
[total_physical_reads]
)
AS
[Total Physical Reads]
,
SUM
(
qs
.
[total_logical_writes]
)
AS
[Total Logical Writes]
,
SUM
(
qs
.
[total_logical_reads]
)
AS
[Total Logical Reads]
,
SUM
(
qs
.
[total_clr_time]
)
/
1000
AS
[Total CLR Time (mSecs)]
,
SUM
(
qs
.
[total_elapsed_time]
)
/
1000
AS
[Total Elapsed Time (mSecs)]
FROM
sys.dm_exec_query_stats
AS
qs
CROSS
APPLY
sys.dm_exec_plan_attributes
(
qs
.
Plan_handle
)
AS
a
WHERE
a
.
[attribute]
=
'dbid'
GROUP
BY
[value]
,
ISNULL
(
DB_NAME
(
CONVERT
(
INT
,
a
.
[value]
)),
'Resource'
)
ORDER
BY
[Total Worker Time (mSecs)]
DESC
0 Comments
Blog - Comment List MSDN TechNet
Comments
Loading...
Leave a Comment
Name
Comment
Please add 2 and 5 and type the answer here:
Post