Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is PAGEIOLATCH_SH wait type in SQL Server?

I have a query that is taking a long time in the middle of a transaction. When I get the wait_type of the process it is PAGEIOLATCH_SH.

What does this wait type mean and how can this be resolved?

like image 253
Ryan Avatar asked Mar 06 '09 22:03

Ryan


People also ask

What are the wait types in SQL Server?

There are two main categories for the SQL Server Wait Statistics; the Single Wait type, where the query is waiting for CPU resource availability and the Resource Wait type, where the query is waiting for a specific resource availability, such as I/O or Memory resources.

What is Sleep_task wait type in SQL Server?

The SLEEP_TASK wait means that a thread is waiting on a resource or waiting for some event to occur, and could indicate background task scheduling, a query plan exchange operator that isn't tracked by CXPACKET, or it could be a hashing operation that spills to tempdb.

What is wait type Cxpacket in SQL Server?

The SQL Server CXPACKET wait type is a result of parallel query execution and indicates that a session is waiting for the synchronization of threads involved in the parallel process to complete.

What is Cxconsumer wait type in SQL Server?

CXPACKET and CXCONSUMER are wait types that indicate that work isn't equally balanced. When you see these wait stats on your server, you'll know that SQL Server is running queries in parallel, but not doing a great job of distributing them across available processors.


1 Answers

From Microsoft documentation:

PAGEIOLATCH_SH

Occurs when a task is waiting on a latch for a buffer that is in an I/O request. The latch request is in Shared mode. Long waits may indicate problems with the disk subsystem.

In practice, this almost always happens due to large scans over big tables. It almost never happens in queries that use indexes efficiently.

If your query is like this:

Select * from <table> where <col1> = <value> order by <PrimaryKey> 

, check that you have a composite index on (col1, col_primary_key).

If you don't have one, then you'll need either a full INDEX SCAN if the PRIMARY KEY is chosen, or a SORT if an index on col1 is chosen.

Both of them are very disk I/O consuming operations on large tables.

like image 115
Quassnoi Avatar answered Sep 24 '22 13:09

Quassnoi