--- title: "SET STATISTICS IO (Transact-SQL)" description: "Use SET STATISTICS IO to display information about the amount of physical and logical IO activity generated by T-SQL statements." author: WilliamDAssafMSFT ms.author: wiassaf ms.date: 06/07/2024 ms.service: sql ms.subservice: t-sql ms.topic: reference f1_keywords: - "SET_STATISTICS_IO_TSQL" - "IO" - "IO_TSQL" - "SET STATISTICS IO" helpviewer_keywords: - "disk I/O statistics [SQL Server]" - "I/O [SQL Server], disk activity information" - "disks [SQL Server], statement statistics" - "STATISTICS IO option" - "statements [SQL Server], statistical information" - "SET STATISTICS IO statement" - "statistical information [SQL Server], disk activity" dev_langs: - "TSQL" --- # SET STATISTICS IO (Transact-SQL) [!INCLUDE [SQL Server Azure SQL Database Azure SQL Managed Instance](../../includes/applies-to-version/sql-asdb-asdbmi.md)] Causes [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] to display information about the amount of physical and logical IO activity generated by [!INCLUDE [tsql](../../includes/tsql-md.md)] statements. Physical IO is related to accessing data pages on disk and logical IO is related to accessing data pages in memory (data cache). :::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: [Transact-SQL syntax conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md) ## Syntax ```syntaxsql SET STATISTICS IO { ON | OFF } ``` ## Output The following table lists and describes the output items. |Output item|Meaning| |-----------------|-------------| | `Table` |Name of the table.| | `Scan count` |Number of seeks or scans started after reaching the leaf level in any direction to retrieve all the values to construct the final dataset for the output.

Scan count is 0 if the index used is a unique index or clustered index on a primary key and you're seeking for only one value. For example, `WHERE Primary_Key_Column = `.
Scan count is 1 when you're searching for one value using a non-unique clustered index defined on a non-primary key column. This process is done to check for duplicate values for the key value that you're searching for. For example, `WHERE Clustered_Index_Key_Column = `.
Scan count is N when N is the number of different seeks or scans started toward the left or right side at the leaf level after locating a key value using the index key.| | `logical reads` |Number of pages read from the data cache.| | `physical reads` |Number of pages read from disk.| | `page server reads` |Number of pages read from page servers. \*\* | | `read-ahead reads` |Number of pages placed into the cache by the query, via the [read-ahead](../../relational-databases/reading-pages.md).| | `page server read-ahead reads` |Number of pages read from page servers and placed into the data cache by the query, via the [read-ahead](../../relational-databases/reading-pages.md). \*\* | | `lob logical reads` |Number of LOB\* pages read from the data cache. | | `lob physical reads` |Number of LOB\* pages read from disk.| | `lob page server reads` |Number of LOB\* pages read from page servers. \*\* | | `lob read-ahead reads` |Number of LOB\* pages placed into the data cache by the query, via the [read-ahead](../../relational-databases/reading-pages.md).| | `lob page server read-ahead reads` |Number of LOB\* pages read from page servers and placed into the data cache by the query, via the [read-ahead](../../relational-databases/reading-pages.md). \*\* | \* Large object binary (LOB) data types include **text**, **ntext**, **image**, **varchar(max)**, **nvarchar(max)**, **varbinary(max)**, or columnstore index pages. \*\* Non-zero for [!INCLUDE [ssazure-sqldb](../../includes/ssazure-sqldb.md)] Hyperscale only. ## Remarks When `STATISTICS IO` is ON, statistical information is displayed, and when OFF, the information isn't displayed. After this option is set ON, all [!INCLUDE [tsql](../../includes/tsql-md.md)] statements return the statistical information until the option is set to OFF. The setting of `SET STATISTICS IO` is set at execute or run time and not at parse time. > [!NOTE] > When Transact-SQL statements retrieve LOB columns, some LOB retrieval operations might require traversing the LOB tree multiple times. This can cause SET STATISTICS IO to report higher than expected logical reads. ## Permissions To use `SET STATISTICS IO`, users must have the appropriate permissions to execute the [!INCLUDE [tsql](../../includes/tsql-md.md)] statement. The SHOWPLAN permission isn't required. ## Examples This example shows how many logical and physical reads are used by [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] as it processes the statements. ```sql USE AdventureWorks2022; GO SET STATISTICS IO ON; GO SELECT * FROM Production.ProductCostHistory WHERE StandardCost < 500.00; GO SET STATISTICS IO OFF; GO ``` Here is the message output: ```output Table 'ProductCostHistory'. Scan count 1, logical reads 76, physical reads 0, page server reads 0, read-ahead reads 0, page server read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob page server reads 0, lob read-ahead reads 0, lob page server read-ahead reads 0. ``` ## Related content - [SET Statements (Transact-SQL)](../../t-sql/statements/set-statements-transact-sql.md) - [SET SHOWPLAN_ALL (Transact-SQL)](../../t-sql/statements/set-showplan-all-transact-sql.md) - [SET STATISTICS TIME (Transact-SQL)](../../t-sql/statements/set-statistics-time-transact-sql.md)