Skip to content

Commit 79b4483

Browse files
authored
Merge pull request #36238 from rwestMSFT/rw-0113-linux-dmvs
[SQL Server 2025] Add new Linux DMVs
2 parents ff84a35 + 4a23f57 commit 79b4483

7 files changed

Lines changed: 623 additions & 65 deletions

docs/linux/sql-server-linux-performance-best-practices.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,5 +509,6 @@ When setting memory limits for [!INCLUDE [ssnoversion-md](../includes/ssnoversio
509509
510510
## Related content
511511
512+
- [Linux related dynamic management views and functions (Transact-SQL)](../relational-databases/system-dynamic-management-views/linux-related-dynamic-management-views-and-functions-transact-sql.md)
512513
- [Walkthrough for the performance features of SQL Server on Linux](sql-server-linux-performance-get-started.md)
513514
- [What is SQL Server on Linux?](sql-server-linux-overview.md)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: "Linux Related Dynamic Management Views and Functions (Transact-SQL)"
3+
description: Linux related dynamic management views and functions (Transact-SQL)
4+
author: rwestMSFT
5+
ms.author: randolphwest
6+
ms.date: 01/13/2026
7+
ms.service: sql
8+
ms.subservice: system-objects
9+
ms.topic: "reference"
10+
helpviewer_keywords:
11+
- "Linux dynamic management objects [SQL Server]"
12+
- "dynamic management objects [SQL Server], Linux"
13+
dev_langs:
14+
- "TSQL"
15+
---
16+
# Linux related dynamic management views and functions (Transact-SQL)
17+
18+
[!INCLUDE [sqlserver2025-linux](../../includes/applies-to-version/sqlserver2025-linux.md)]
19+
20+
The following dynamic management objects return system-level Linux metrics beyond SQL Server, for a comprehensive visibility into overall host performance.
21+
22+
These objects provide detailed CPU statistics, real-time network interface activity (bytes and packets sent and received, errors, drops, and collisions), and disk I/O statistics for each storage device.
23+
24+
## In this section
25+
26+
- [sys.dm_os_linux_cpu_stats](sys-dm-os-linux-cpu-stats-transact-sql.md)
27+
- [sys.dm_os_linux_disk_stats](sys-dm-os-linux-disk-stats-transact-sql.md)
28+
- [sys.dm_os_linux_net_stats](sys-dm-os-linux-net-stats-transact-sql.md)
29+
30+
## Related content
31+
32+
- [Performance best practices and configuration guidelines for SQL Server on Linux](../../linux/sql-server-linux-performance-best-practices.md)
33+
- [System dynamic management views](system-dynamic-management-views.md)
34+
- [Transact-SQL reference (Database Engine)](../../t-sql/language-reference.md)
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
---
2+
title: "sys.dm_os_linux_cpu_stats (Transact-SQL)"
3+
description: sys.dm_os_linux_cpu_stats returns a table with detailed Linux CPU statistics, offering system-level insights beyond SQL Server.
4+
author: rwestMSFT
5+
ms.author: randolphwest
6+
ms.date: 01/13/2026
7+
ms.service: sql
8+
ms.subservice: system-objects
9+
ms.topic: "reference"
10+
f1_keywords:
11+
- "dm_os_linux_cpu_stats"
12+
- "sys.dm_os_linux_cpu_stats_TSQL"
13+
- "dm_os_linux_cpu_stats_TSQL"
14+
- "sys.dm_os_linux_cpu_stats"
15+
helpviewer_keywords:
16+
- "sys.dm_os_linux_cpu_stats dynamic management view"
17+
dev_langs:
18+
- "TSQL"
19+
---
20+
# sys.dm_os_linux_cpu_stats (Transact-SQL)
21+
22+
[!INCLUDE [sqlserver2025-linux](../../includes/applies-to-version/sqlserver2025-linux.md)]
23+
24+
Returns a table with detailed Linux CPU statistics, offering system-level insights beyond SQL Server, in [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)] Cumulative Update (CU) 1 and later versions.
25+
26+
| Column name | Data type | Nullable | Description |
27+
| --- | --- | --- | --- |
28+
| `uptime_secs` | **float** | No | Seconds since system startup. |
29+
| `loadavg_1min` | **float** | No | Number of jobs in the run queue (ready or waiting for disk I/O) over 1 minute. |
30+
| `user_time_cs` | **bigint** | No | `USER_HZ` spent in user mode. |
31+
| `nice_time_cs` | **bigint** | No | `USER_HZ` spent in user mode with low priority (`nice`). |
32+
| `system_time_cs` | **bigint** | No | `USER_HZ` spent in system mode. |
33+
| `idle_time_cs` | **bigint** | No | `USER_HZ` spent in the idle task. |
34+
| `iowait_time_cs` | **bigint** | No | `USER_HZ` waiting for I/O to complete. |
35+
| `irq_time_cs` | **bigint** | No | `USER_HZ` servicing interrupts. |
36+
| `softirq_time_cs` | **bigint** | No | `USER_HZ` servicing SoftIRQs. |
37+
| `interrupt_cnt` | **bigint** | No | Number of interrupts serviced since system startup. |
38+
| `csw_cnt` | **bigint** | No | Number of context switches since system startup. |
39+
| `boot_time_secs` | **bigint** | No | Boot time, in seconds since Unix epoch. |
40+
| `total_forks_cnt` | **bigint** | No | Number of forks since system startup. |
41+
| `proc_runable_cnt` | **bigint** | No | Number of processes in runnable state. |
42+
| `proc_ioblocked_cnt` | **bigint** | No | Number of processes blocked waiting for I/O. |
43+
| `C3_time` | **bigint** | No | [!INCLUDE [ssinternalonly-md](../../includes/ssinternalonly-md.md)] |
44+
| `C2_time` | **bigint** | No | [!INCLUDE [ssinternalonly-md](../../includes/ssinternalonly-md.md)] |
45+
| `C1_time` | **bigint** | No | [!INCLUDE [ssinternalonly-md](../../includes/ssinternalonly-md.md)] |
46+
| `C3_count` | **bigint** | No | [!INCLUDE [ssinternalonly-md](../../includes/ssinternalonly-md.md)] |
47+
| `C2_count` | **bigint** | No | [!INCLUDE [ssinternalonly-md](../../includes/ssinternalonly-md.md)] |
48+
| `C1_count` | **bigint** | No | [!INCLUDE [ssinternalonly-md](../../includes/ssinternalonly-md.md)] |
49+
50+
## Permissions
51+
52+
Requires `VIEW SERVER PERFORMANCE STATE` permission on the server.
53+
54+
## Remarks
55+
56+
This DMV provides cumulative statistics since the system was started.
57+
58+
Values aren't limited to SQL Server activity; they reflect the entire Linux host.
59+
60+
For more information on interpreting Linux CPU statistics, see the `proc_stat(5)` manual page for your distribution.
61+
62+
Use this DMV with other Linux-specific DMVs, such as [sys.dm_os_linux_disk_stats](sys-dm-os-linux-disk-stats-transact-sql.md) and [sys.dm_os_linux_net_stats](sys-dm-os-linux-net-stats-transact-sql.md), for holistic monitoring.
63+
64+
### Usage scenarios
65+
66+
- **Diagnose CPU saturation**: Use `loadavg_1min`, `proc_runable_cnt`, and `user_time_cs` to identify if the system is under heavy CPU load.
67+
68+
- **Investigate I/O waits**: High `iowait_time_cs` or `proc_ioblocked_cnt` values could indicate storage bottlenecks.
69+
70+
- **Analyze system responsiveness**: Frequent context switches (`csw_cnt`) or interrupts (`interrupt_cnt`) can signal issues with system scheduling or hardware.
71+
72+
- **Correlate SQL Server performance with system activity**: Since these metrics are system-wide, they help distinguish between SQL Server-specific and broader OS-level issues.
73+
74+
## Examples
75+
76+
### A. Current CPU statistics for the system
77+
78+
Use `sys.dm_os_linux_cpu_stats` to get the current CPU statistics for the system. This example is a one-time snapshot that shows common signals that operations teams frequently monitor.
79+
80+
```sql
81+
SELECT GETDATE() AS sample_time,
82+
uptime_secs,
83+
loadavg_1min,
84+
proc_runable_cnt,
85+
proc_ioblocked_cnt,
86+
interrupt_cnt,
87+
csw_cnt,
88+
user_time_cs,
89+
system_time_cs,
90+
idle_time_cs,
91+
iowait_time_cs
92+
FROM sys.dm_os_linux_cpu_stats;
93+
```
94+
95+
### B. Correlate host pressure with SQL schedulers
96+
97+
Run the following example query to get a host snapshot.
98+
99+
```sql
100+
SELECT loadavg_1min,
101+
proc_runable_cnt,
102+
proc_ioblocked_cnt,
103+
interrupt_cnt,
104+
csw_cnt
105+
FROM sys.dm_os_linux_cpu_stats;
106+
```
107+
108+
The following query returns information about SQL scheduler pressure, excluding DAC and hidden schedulers.
109+
110+
If schedulers show high `runnable_tasks_count` and host `loadavg_1min` is more than the CPU count with elevated `proc_runable_cnt`, the system is likely CPU-bound. If SQL runnable is low but the host `proc_ioblocked_cnt` and I/O wait rates are high, storage is your suspect.
111+
112+
> [!NOTE]
113+
> Host metrics are system wide, and aren't limited to SQL Server.
114+
115+
```sql
116+
SELECT scheduler_id,
117+
runnable_tasks_count,
118+
current_tasks_count,
119+
work_queue_count,
120+
is_online,
121+
is_scheduler_online,
122+
load_factor
123+
FROM sys.dm_os_schedulers
124+
WHERE scheduler_id < 255;
125+
```
126+
127+
## Related content
128+
129+
- [sys.dm_os_linux_disk_stats (Transact-SQL)](sys-dm-os-linux-disk-stats-transact-sql.md)
130+
- [sys.dm_os_linux_net_stats (Transact-SQL)](sys-dm-os-linux-net-stats-transact-sql.md)
131+
- [Performance best practices and configuration guidelines for SQL Server on Linux](../../linux/sql-server-linux-performance-best-practices.md)
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
---
2+
title: "sys.dm_os_linux_disk_stats (Transact-SQL)"
3+
description: sys.dm_os_linux_disk_stats returns a table with detailed Linux CPU statistics, offering system-level insights beyond SQL Server.
4+
author: rwestMSFT
5+
ms.author: randolphwest
6+
ms.date: 01/13/2026
7+
ms.service: sql
8+
ms.subservice: system-objects
9+
ms.topic: "reference"
10+
f1_keywords:
11+
- "dm_os_linux_disk_stats"
12+
- "sys.dm_os_linux_disk_stats_TSQL"
13+
- "dm_os_linux_disk_stats_TSQL"
14+
- "sys.dm_os_linux_disk_stats"
15+
helpviewer_keywords:
16+
- "sys.dm_os_linux_disk_stats dynamic management view"
17+
dev_langs:
18+
- "TSQL"
19+
---
20+
# sys.dm_os_linux_disk_stats (Transact-SQL)
21+
22+
[!INCLUDE [sqlserver2025-linux](../../includes/applies-to-version/sqlserver2025-linux.md)]
23+
24+
Returns a table with disk I/O statistics for each Linux device, showing total activity beyond SQL Server, in [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)] Cumulative Update (CU) 1 and later versions.
25+
26+
The DMV returns one row per Linux disk device.
27+
28+
| Column name | Data type | Nullable | Description |
29+
| --- | --- | --- | --- |
30+
| `dev_name` | **nvarchar(256)** | No | Device name. |
31+
| `major_num` | **bigint** | No | Major device number. |
32+
| `minor_num` | **bigint** | No | Minor device number. |
33+
| `reads_completed` | **bigint** | No | Number of reads completed. |
34+
| `reads_merged` | **bigint** | No | Number of adjacent reads merged into a single request. |
35+
| `sectors_read` | **bigint** | No | Number of sectors read. |
36+
| `read_time_ms` | **bigint** | No | Milliseconds spent servicing reads. |
37+
| `writes_completed` | **bigint** | No | Number of writes completed. |
38+
| `writes_merged` | **bigint** | No | Number of adjacent writes merged into a single request. |
39+
| `sectors_written` | **bigint** | No | Number of sectors written. |
40+
| `write_time_ms` | **bigint** | No | Milliseconds spent servicing writes. |
41+
| `ios_in_progress` | **bigint** | No | Number of IOs currently in request queues. |
42+
| `io_time_ms` | **bigint** | No | Milliseconds the device spent doing I/O. |
43+
| `weighted_io_time_ms` | **bigint** | No | Weighted number of milliseconds spent doing I/Os. |
44+
45+
## Permissions
46+
47+
Requires `VIEW SERVER PERFORMANCE STATE` permission on the server.
48+
49+
## Remarks
50+
51+
- **Host level scope**:
52+
The results reflect all activity on the device, including SQL Server, other services, and background system operations. To attribute database workload effects, correlate these results with SQL Server wait statistics, such as `WRITELOG` and `PAGEIOLATCH_*`.
53+
54+
- **Interpret time columns**:
55+
56+
| Measure | Calculation |
57+
| --- | --- |
58+
| Average read latency (ms/op) | `read_time_ms / NULLIF(reads_completed, 0)` |
59+
| Average write latency (ms/op) | `write_time_ms / NULLIF(writes_completed, 0)` |
60+
| Device utilization (%) over an interval | `io_time_ms / (elapsed_ms) * 100` |
61+
| Average queue length | `weighted_io_time_ms / elapsed_ms` |
62+
63+
- **Sector units**: Linux commonly reports sectors in 512-byte units. Validate your environment's sector size and adjust calculations accordingly.
64+
65+
- **Use with care in multitenant hosts**: High values can originate from non-SQL Server workloads. Correlate with system tools or other DMVs for attribution.
66+
67+
Use this DMV with other Linux-specific DMVs, such as [sys.dm_os_linux_disk_stats](sys-dm-os-linux-disk-stats-transact-sql.md) and [sys.dm_os_linux_net_stats](sys-dm-os-linux-net-stats-transact-sql.md), for holistic monitoring.
68+
69+
### Usage scenarios
70+
71+
- **Log flush slowness (availability groups or standalone)**: High `write_time_ms` / `writes_completed` with elevated `io_time_ms` indicates device-level write latency. Corroborate with `WRITELOG` waits.
72+
73+
- **Checkpoint or read heavy workloads**: Rising `read_time_ms` / `reads_completed` with sustained `read_MBps` suggests throughput constrained by latency. Consider storage tier or queue settings.
74+
75+
- **Noisy neighbors on shared hosts**: Spikes in `device_utilization_pct` and `avg_queue_length` without corresponding SQL Server workload changes imply external I/O pressure. Validate with host monitoring.
76+
77+
## Examples
78+
79+
### A. Current device activity snapshot
80+
81+
This query returns an activity snapshot for the current storage device.
82+
83+
```sql
84+
SELECT dev_name,
85+
reads_completed,
86+
read_time_ms,
87+
writes_completed,
88+
write_time_ms,
89+
ios_in_progress,
90+
io_time_ms,
91+
weighted_io_time_ms
92+
FROM sys.dm_os_linux_disk_stats
93+
ORDER BY io_time_ms DESC;
94+
```
95+
96+
### B. Latency and throughput over a 10-second sample window
97+
98+
The script samples the DMV twice and computes deltas for latency (milliseconds per operation), throughput (MB per second), utilization (percentage), and queue length. Adjust `@SectorBytes` to match your device configuration.
99+
100+
```sql
101+
DECLARE @SectorBytes AS INT = 512;
102+
103+
-- verify sector size for your environment
104+
DECLARE @SampleMs AS INT = 10000;
105+
106+
IF OBJECT_ID('tempdb..#before') IS NOT NULL
107+
DROP TABLE #before;
108+
109+
IF OBJECT_ID('tempdb..#after') IS NOT NULL
110+
DROP TABLE #after;
111+
112+
SELECT dev_name,
113+
reads_completed,
114+
reads_merged,
115+
sectors_read,
116+
read_time_ms,
117+
writes_completed,
118+
writes_merged,
119+
sectors_written,
120+
write_time_ms,
121+
ios_in_progress,
122+
io_time_ms,
123+
weighted_io_time_ms
124+
INTO #before
125+
FROM sys.dm_os_linux_disk_stats;
126+
127+
WAITFOR DELAY '00:00:10';
128+
129+
SELECT dev_name,
130+
reads_completed,
131+
reads_merged,
132+
sectors_read,
133+
read_time_ms,
134+
writes_completed,
135+
writes_merged,
136+
sectors_written,
137+
write_time_ms,
138+
ios_in_progress,
139+
io_time_ms,
140+
weighted_io_time_ms
141+
INTO #after
142+
FROM sys.dm_os_linux_disk_stats;
143+
144+
WITH deltas
145+
AS (SELECT a.dev_name,
146+
a.reads_completed - b.reads_completed AS d_reads,
147+
a.read_time_ms - b.read_time_ms AS d_read_ms,
148+
a.sectors_read - b.sectors_read AS d_read_sectors,
149+
a.writes_completed - b.writes_completed AS d_writes,
150+
a.write_time_ms - b.write_time_ms AS d_write_ms,
151+
a.sectors_written - b.sectors_written AS d_write_sectors,
152+
a.io_time_ms - b.io_time_ms AS d_io_ms,
153+
a.weighted_io_time_ms - b.weighted_io_time_ms AS d_weighted_io_ms
154+
FROM #after AS a
155+
INNER JOIN #before AS b
156+
ON a.dev_name = b.dev_name)
157+
SELECT dev_name,
158+
-- latency (ms/op)
159+
CAST (d_read_ms / NULLIF (d_reads, 0) AS DECIMAL (18, 2)) AS avg_read_latency_ms,
160+
CAST (d_write_ms / NULLIF (d_writes, 0) AS DECIMAL (18, 2)) AS avg_write_latency_ms,
161+
-- throughput (MB/s)
162+
CAST ((d_read_sectors * @SectorBytes) / (@SampleMs / 1000.0) / 1048576.0 AS DECIMAL (18, 2)) AS read_MBps,
163+
CAST ((d_write_sectors * @SectorBytes) / (@SampleMs / 1000.0) / 1048576.0 AS DECIMAL (18, 2)) AS write_MBps,
164+
-- utilization (%)
165+
CAST (d_io_ms / @SampleMs * 100.0 AS DECIMAL (5, 2)) AS device_utilization_pct,
166+
-- average queue length
167+
CAST (d_weighted_io_ms / @SampleMs AS DECIMAL (18, 2)) AS avg_queue_length
168+
FROM deltas
169+
ORDER BY device_utilization_pct DESC;
170+
```
171+
172+
### C. Identify devices with high merge ratios
173+
174+
This example identifies devices with high merge ratios, indicating possible I/O coalescing.
175+
176+
```sql
177+
SELECT dev_name,
178+
reads_completed,
179+
reads_merged,
180+
writes_completed,
181+
writes_merged,
182+
CAST (reads_merged / NULLIF (reads_completed, 0) AS DECIMAL (10, 2)) AS read_merge_ratio,
183+
CAST (writes_merged / NULLIF (writes_completed, 0) AS DECIMAL (10, 2)) AS write_merge_ratio
184+
FROM sys.dm_os_linux_disk_stats
185+
ORDER BY write_merge_ratio DESC, read_merge_ratio DESC;
186+
```
187+
188+
### D. Watch queue depth live
189+
190+
This example shows the live queue depth, which is useful for incident triage.
191+
192+
```sql
193+
SELECT TOP (20) dev_name,
194+
ios_in_progress,
195+
io_time_ms,
196+
weighted_io_time_ms
197+
FROM sys.dm_os_linux_disk_stats
198+
ORDER BY ios_in_progress DESC,
199+
weighted_io_time_ms DESC;
200+
```
201+
202+
## Related content
203+
204+
- [sys.dm_os_linux_cpu_stats (Transact-SQL)](sys-dm-os-linux-cpu-stats-transact-sql.md)
205+
- [sys.dm_os_linux_net_stats (Transact-SQL)](sys-dm-os-linux-net-stats-transact-sql.md)
206+
- [Performance best practices and configuration guidelines for SQL Server on Linux](../../linux/sql-server-linux-performance-best-practices.md)

0 commit comments

Comments
 (0)