Skip to content

Commit 67cba48

Browse files
authored
Merge pull request #35962 from rwestMSFT/rw-1128-refresh-dmv
Refresh sys.dm_io_virtual_file_stats article
2 parents 3ff0f5e + c3e7bb5 commit 67cba48

File tree

2 files changed

+86
-86
lines changed

2 files changed

+86
-86
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
author: rwestMSFT
33
ms.author: randolphwest
4-
ms.date: 05/10/2023
4+
ms.date: 11/28/2025
55
ms.service: sql
66
ms.topic: include
77
---
8-
AdventureWorks2022
8+
AdventureWorks2025
Lines changed: 84 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: "sys.dm_io_virtual_file_stats (Transact-SQL)"
3-
description: sys.dm_io_virtual_file_stats (Transact-SQL)
3+
description: sys.dm_io_virtual_file_stats returns I/O statistics for data and log files.
44
author: rwestMSFT
55
ms.author: randolphwest
6-
ms.date: "06/19/2023"
6+
ms.date: 11/28/2025
77
ms.service: sql
88
ms.subservice: system-objects
99
ms.topic: "reference"
@@ -21,109 +21,109 @@ dev_langs:
2121
monikerRange: "=azuresqldb-current || =azure-sqldw-latest || >=aps-pdw-2016 || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric-sqldb"
2222
---
2323
# sys.dm_io_virtual_file_stats (Transact-SQL)
24+
2425
[!INCLUDE [sql-asdb-asdbmi-asa-pdw-fabricsqldb](../../includes/applies-to-version/sql-asdb-asdbmi-asa-pdw-fabricsqldb.md)]
2526

26-
Returns I/O statistics for data and log files. This dynamic management function replaces the [fn_virtualfilestats](../../relational-databases/system-functions/sys-fn-virtualfilestats-transact-sql.md) function.
27-
27+
Returns I/O statistics for data and log files. This dynamic management function replaces the [fn_virtualfilestats](../system-functions/sys-fn-virtualfilestats-transact-sql.md) function.
28+
2829
> [!NOTE]
29-
> To call this from [!INCLUDE[ssazuresynapse-md](../../includes/ssazuresynapse-md.md)], use the name **sys.dm_pdw_nodes_io_virtual_file_stats**. [!INCLUDE[synapse-analytics-od-unsupported-syntax](../../includes/synapse-analytics-od-unsupported-syntax.md)]
30+
> To call this dynamic management view (DMV) from [!INCLUDE [ssazuresynapse-md](../../includes/ssazuresynapse-md.md)], use the name `sys.dm_pdw_nodes_io_virtual_file_stats` [!INCLUDE [synapse-analytics-od-unsupported-syntax](../../includes/synapse-analytics-od-unsupported-syntax.md)]
3031
31-
## Syntax
32-
33-
```
34-
-- Syntax for SQL Server and Azure SQL Database
32+
## Syntax
3533

36-
sys.dm_io_virtual_file_stats (
37-
{ database_id | NULL },
38-
{ file_id | NULL }
39-
)
40-
```
34+
Syntax for SQL Server and Azure SQL Database:
35+
36+
```syntaxsql
37+
sys.dm_io_virtual_file_stats (
38+
{ database_id | NULL } ,
39+
{ file_id | NULL }
40+
)
41+
```
4142

42-
```
43-
-- Syntax for Azure Synapse Analytics
43+
Syntax for Azure Synapse Analytics:
4444

45+
```syntaxsql
4546
sys.dm_pdw_nodes_io_virtual_file_stats
4647
```
47-
48-
## Arguments
49-
50-
51-
*database_id* | NULL
52-
53-
**Applies to:** [!INCLUDE[sql2008-md](../../includes/sql2008-md.md)] and later, Azure SQL Database
54-
55-
ID of the database. *database_id* is int, with no default. Valid inputs are the ID number of a database or NULL. When NULL is specified, all databases in the instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] are returned.
56-
57-
The built-in function [DB_ID](../../t-sql/functions/db-id-transact-sql.md) can be specified.
58-
59-
*file_id* | NULL
60-
61-
**Applies to:** [!INCLUDE[sql2008-md](../../includes/sql2008-md.md)] and later, Azure SQL Database
62-
63-
ID of the file. *file_id* is int, with no default. Valid inputs are the ID number of a file or NULL. When NULL is specified, all files on the database are returned.
64-
65-
The built-in function [FILE_IDEX](../../t-sql/functions/file-idex-transact-sql.md) can be specified, and refers to a file in the current database.
66-
67-
## Table Returned
68-
69-
|Column name|Data type|Description|
70-
|-----------------|---------------|-----------------|
71-
|**database_name**|**sysname**|**Does not apply to:**: [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)].<br /><br /> Database name.</br></br>For Azure Synapse Analytics, this is the name of the database stored on the node which is identified by pdw_node_id. Each node has one tempdb database that has 13 files. Each node also has one database per distribution, and each distribution database has 5 files. For example, if each node contains 4 distributions, the results show 20 distribution database files per pdw_node_id.
72-
|**database_id**|**smallint**|ID of database. <br /><br />In [!INCLUDE [ssazure-sqldb](../../includes/ssazure-sqldb.md)], the values are unique within a single database or an elastic pool, but not within a logical server.|
73-
|**file_id**|**smallint**|ID of file.|
74-
|**sample_ms**|**bigint**|Number of milliseconds since the computer was started. This column can be used to compare different outputs from this function.</br></br>The data type is **int** for [!INCLUDE[sql2008-md](../../includes/sql2008-md.md)] through [!INCLUDE[ssSQL14](../../includes/sssql14-md.md)]. In these versions, the value will reset to 0 after approximately 25 days of continuous database engine uptime.|
75-
|**num_of_reads**|**bigint**|Number of reads issued on the file.|
76-
|**num_of_bytes_read**|**bigint**|Total number of bytes read on this file.|
77-
|**io_stall_read_ms**|**bigint**|Total time, in milliseconds, that the users waited for reads issued on the file.|
78-
|**num_of_writes**|**bigint**|Number of writes made on this file.|
79-
|**num_of_bytes_written**|**bigint**|Total number of bytes written to the file.|
80-
|**io_stall_write_ms**|**bigint**|Total time, in milliseconds, that users waited for writes to be completed on the file.|
81-
|**io_stall**|**bigint**|Total time, in milliseconds, that users waited for I/O to be completed on the file.|
82-
|**size_on_disk_bytes**|**bigint**|Number of bytes used on the disk for this file. For sparse files, this number is the actual number of bytes on the disk that are used for database snapshots.|
83-
|**file_handle**|**varbinary**|Windows file handle for this file.|
84-
|**io_stall_queued_read_ms**|**bigint**|**Does not apply to:**: [!INCLUDE[sql2008-md](../../includes/sql2008-md.md)] through [!INCLUDE[ssSQL12](../../includes/sssql11-md.md)].<br /><br /> Total IO latency introduced by IO resource governance for reads. Is not nullable. For more information, see [sys.dm_resource_governor_resource_pools &#40;Transact-SQL&#41;](../../relational-databases/system-dynamic-management-views/sys-dm-resource-governor-resource-pools-transact-sql.md).|
85-
|**io_stall_queued_write_ms**|**bigint**|**Does not apply to:**: [!INCLUDE[sql2008-md](../../includes/sql2008-md.md)] through [!INCLUDE[ssSQL12](../../includes/sssql11-md.md)].<br /><br /> Total IO latency introduced by IO resource governance for writes. Is not nullable.|
86-
|**pdw_node_id**|**int**|**Applies to:** [!INCLUDE[ssazuresynapse-md](../../includes/ssazuresynapse-md.md)]</br></br>Identifier of the node for the distribution.
87-
48+
49+
## Arguments
50+
51+
#### *database_id* | NULL
52+
53+
**Applies to**: [!INCLUDE [sql2008-md](../../includes/sql2008-md.md)] and later, Azure SQL Database
54+
55+
ID of the database. *database_id* is int, with no default. Valid inputs are the ID number of a database or `NULL`. When `NULL` is specified, all databases in the instance of [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] are returned.
56+
57+
The built-in function [DB_ID](../../t-sql/functions/db-id-transact-sql.md) can be specified.
58+
59+
#### *file_id* | NULL
60+
61+
**Applies to**: [!INCLUDE [sql2008-md](../../includes/sql2008-md.md)] and later, Azure SQL Database
62+
63+
ID of the file. *file_id* is int, with no default. Valid inputs are the ID number of a file or `NULL`. When `NULL` is specified, all files on the database are returned.
64+
65+
The built-in function [FILE_IDEX](../../t-sql/functions/file-idex-transact-sql.md) can be specified, and refers to a file in the current database.
66+
67+
## Table returned
68+
69+
| Column name | Data type | Description |
70+
| --- | --- | --- |
71+
| `database_name` | **sysname** | Database name.<br /><br />For Azure Synapse Analytics, this is the name of the database stored on the node identified by `pdw_node_id`. Each node has one `tempdb` database that has 13 files. Each node also has one database per distribution, and each distribution database has five files. For example, if each node contains four distributions, the results show 20 distribution database files per `pdw_node_id`.<br /><br />**Does not apply to**: [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)]. |
72+
| `database_id` | **smallint** | ID of database.<br /><br />In [!INCLUDE [ssazure-sqldb](../../includes/ssazure-sqldb.md)], the values are unique within a single database or an elastic pool, but not within a logical server. |
73+
| `file_id` | **smallint** | ID of file. |
74+
| `sample_ms` | **bigint** | Number of milliseconds since the computer was started. This column can be used to compare different outputs from this function.<br /><br />The data type is **int** for [!INCLUDE [ssSQL14](../../includes/sssql14-md.md)] and earlier versions. In these versions, the value will reset to 0 after approximately 25 days of continuous database engine uptime. |
75+
| `num_of_reads` | **bigint** | Number of reads issued on the file. |
76+
| `num_of_bytes_read` | **bigint** | Total number of bytes read on this file. |
77+
| `io_stall_read_ms` | **bigint** | Total time, in milliseconds, that the users waited for reads issued on the file. |
78+
| `num_of_writes` | **bigint** | Number of writes made on this file. |
79+
| `num_of_bytes_written` | **bigint** | Total number of bytes written to the file. |
80+
| `io_stall_write_ms` | **bigint** | Total time, in milliseconds, that users waited for writes to be completed on the file. |
81+
| `io_stall` | **bigint** | Total time, in milliseconds, that users waited for I/O to be completed on the file. |
82+
| `size_on_disk_bytes` | **bigint** | Number of bytes used on the disk for this file. For sparse files, this number is the actual number of bytes on the disk that are used for database snapshots. |
83+
| `file_handle` | **varbinary** | Windows file handle for this file. |
84+
| `io_stall_queued_read_ms` | **bigint** | Total IO latency introduced by IO resource governance for reads. Not nullable. For more information, see [sys.dm_resource_governor_resource_pools](sys-dm-resource-governor-resource-pools-transact-sql.md).<br /><br />**Does not apply to**: [!INCLUDE [ssSQL12](../../includes/sssql11-md.md)] and earlier versions. |
85+
| `io_stall_queued_write_ms` | **bigint** | Total IO latency introduced by IO resource governance for writes. Not nullable.<br /><br />**Does not apply to**: [!INCLUDE [ssSQL12](../../includes/sssql11-md.md)] and earlier versions. |
86+
| `pdw_node_id` | **int** | Identifier of the node for the distribution.<br /><br />**Applies to**: [!INCLUDE [ssazuresynapse-md](../../includes/ssazuresynapse-md.md)] |
87+
8888
## Remarks
89+
8990
The counters are initialized to empty whenever the SQL Server (MSSQLSERVER) service is started.
90-
91-
## Permissions
92-
Requires VIEW SERVER STATE permission. For more information, see [Dynamic Management Views and Functions &#40;Transact-SQL&#41;](~/relational-databases/system-dynamic-management-views/system-dynamic-management-views.md).
93-
94-
### Permissions for SQL Server 2022 and later
9591

96-
Requires VIEW SERVER PERFORMANCE STATE permission on the server.
92+
## Permissions
93+
94+
[!INCLUDE [sssql19-md](../../includes/sssql19-md.md)] and earlier versions require `VIEW SERVER STATE` permission.
95+
96+
[!INCLUDE [sssql22-md](../../includes/sssql22-md.md)] and later versions require `VIEW SERVER PERFORMANCE STATE` permission on the server.
97+
98+
## Examples
9799

98-
## Examples
100+
[!INCLUDE [article-uses-adventureworks](../../includes/article-uses-adventureworks.md)]
99101

100102
### A. Return statistics for a log file
101103

102-
**Applies to:** [!INCLUDE[sql2008-md](../../includes/sql2008-md.md)] and later, Azure SQL Database
104+
**Applies to**: [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] and [!INCLUDE [ssazure-sqldb](../../includes/ssazure-sqldb.md)]
105+
106+
The following example returns statistics for the log file in the [!INCLUDE [ssSampleDBnormal](../../includes/sssampledbnormal-md.md)] database.
107+
108+
```sql
109+
SELECT *
110+
FROM sys.dm_io_virtual_file_stats(DB_ID(N'AdventureWorks2025'), 2);
111+
```
103112

104-
The following example returns statistics for the log file in the [!INCLUDE[ssSampleDBnormal](../../includes/sssampledbnormal-md.md)] database.
105-
106-
```sql
107-
SELECT * FROM sys.dm_io_virtual_file_stats(DB_ID(N'AdventureWorks2022'), 2);
108-
GO
109-
```
110-
111113
### B. Return statistics for file in tempdb
112114

113-
**Applies to:** Azure Synapse Analytics
115+
**Applies to**: Azure Synapse Analytics
114116

115117
```sql
116-
SELECT * FROM sys.dm_pdw_nodes_io_virtual_file_stats
117-
WHERE database_name = 'tempdb' AND file_id = 2;
118-
118+
SELECT *
119+
FROM sys.dm_pdw_nodes_io_virtual_file_stats
120+
WHERE database_name = 'tempdb'
121+
AND file_id = 2;
119122
```
120123

121-
## See also
122-
[Dynamic Management Views and Functions &#40;Transact-SQL&#41;](~/relational-databases/system-dynamic-management-views/system-dynamic-management-views.md)
123-
[I O Related Dynamic Management Views and Functions &#40;Transact-SQL&#41;](../../relational-databases/system-dynamic-management-views/i-o-related-dynamic-management-views-and-functions-transact-sql.md)
124-
[sys.database_files &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/sys-database-files-transact-sql.md)
125-
[sys.master_files &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/sys-master-files-transact-sql.md)
126-
127-
128-
124+
## Related content
129125

126+
- [System dynamic management views](system-dynamic-management-views.md)
127+
- [I/O Related Dynamic Management Views and Functions (Transact-SQL)](i-o-related-dynamic-management-views-and-functions-transact-sql.md)
128+
- [sys.database_files](../system-catalog-views/sys-database-files-transact-sql.md)
129+
- [sys.master_files](../system-catalog-views/sys-master-files-transact-sql.md)

0 commit comments

Comments
 (0)