-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathmemory-analysis.sql
More file actions
37 lines (35 loc) · 1.18 KB
/
memory-analysis.sql
File metadata and controls
37 lines (35 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
-----------------------------------------------------------------
-- Memory Analysis
--
-- rudi@babaluga.com, go ahead license
-----------------------------------------------------------------
SET NOCOUNT ON;
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT
'Max server memory' AS metric,
CAST(value_in_use AS VARCHAR(20)) + ' Mo' AS [value]
FROM sys.configurations WHERE name = 'max server memory (MB)'
UNION ALL
SELECT
'Total memory used',
CAST(SUM(pages_kb) / 1024 AS VARCHAR(20)) + ' Mb'
FROM sys.dm_os_memory_clerks
UNION ALL
SELECT
'Buffer Pool',
CAST(cntr_value / 1024 AS VARCHAR(20)) + ' Mb'
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Database pages' AND object_name LIKE '%Buffer Manager%'
UNION ALL
SELECT
'Page Life Expectancy',
CAST(cntr_value AS VARCHAR(20)) + ' seconds'
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Page life expectancy' AND object_name LIKE '%Buffer Manager%'
UNION ALL
SELECT
'Memory Grants Pending',
CAST(cntr_value AS VARCHAR(20)) + ' queries'
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Memory Grants Pending' AND object_name LIKE '%Memory Manager%'
OPTION (RECOMPILE, MAXDOP 1);