Sunday 13 October 2024

Physical read in SQL server

 Number of pages read from disk. It show how many pages are requested by query processor from the storage engine and storage engine retrieve it from secondary storage (HDD) and put it into primary storage (cache).


Physical reads are considered expensive in terms of performance as accessing disk is much slower than accessing memory. A high number of physical reads can significantly affect query performance. As disk I/O is slower compared to accessing data in memory. If we want to optimize our query then need to reduce physical reads by increasing the buffer pool size, optimizing queries or ensuring the necessary data in cache in memory.

Running the below script, we are using AdventureWorks2019 DB.

select * from Production.TransactionHistory where ProductID=329

 

Here we can see the 3 pages are physical read and 788 is read-ahead read. When we have executed this query first time then physical read & read-ahead read happen. When we will run this script second time then it will read only logical read because the data are stored on the buffer pool. See the below.

This is faster than the first run because it is not reading the data from physical read. 

No comments:

Post a Comment

If you have any doubt, please let me know.

Popular Posts