Home
%3CLINGO-SUB%20id%3D%22lingo-sub-333983%22%20slang%3D%22en-US%22%3ESlow%20I%2FO%20-%20SQL%20Server%20and%20disk%20I%2FO%20performance%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-333983%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3E%20First%20published%20on%20MSDN%20on%20Dec%2006%2C%202012%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThis%20provides%20a%20general%20approach%20on%20how%20to%20troubleshoot%20SQL%20Server%20I%2FO-related%20issues.%20My%20belief%20is%20that%20if%20you%20truly%20understand%20this%2C%20you%20are%20empowered%20to%20solve%20the%20disk%20I%2FO%20challenges%20yourself.%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%20Define%20slow%20disk%20performance%3A%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20metric%20commonly%20used%20to%20measure%20slow%20I%2FO%20performance%20is%20the%20metric%20that%20measure%20how%20fast%20the%20I%2FO%20subsystem%20is%20servicing%20each%20I%2FO%20request%20on%20the%20average%20in%20terms%20of%20clock%20time.%20The%20specific%20Performance%20monitor%20counters%20that%20measure%20I%2FO%20latency%20in%20Windows%20are%20%3CSTRONG%3E%20Avg%20Disk%20sec%2F%20Read%20%3C%2FSTRONG%3E%20%2C%20%3CSTRONG%3E%20Avg.%20Disk%20sec%2FWrite%20%3C%2FSTRONG%3E%20and%20%3CSTRONG%3E%20Avg.%20Disk%20sec%2FTransfer%20%3C%2FSTRONG%3E%20(cumulative%20of%20both%20reads%20and%20writes).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFrom%20a%20SQL%20Server%20perspective%20things%20are%20no%20different.%20We%20usually%20look%20at%20whether%20SQL%20Server%20reports%20any%20I%2FO%20bottlenecks%20measured%20in%20clock%20time%20(milliseconds).%20SQL%20Server%20makes%20I%2FO%20requests%20to%20the%20OS%20by%20calling%20Win32%20functions%20-%20WriteFile()%2C%20ReadFile()%2C%20WriteFileGather()%2C%20ReadFileScatter().%20When%20it%20posts%20an%20I%2FO%20requests%2C%20SQL%20Server%20times%20the%20request%20and%20reports%20how%20long%20that%20request%20took.%20SQL%20Server%20uses%20Wait%20Types%20to%20indicate%20I%2FO%20waits%20at%20different%20places%20in%20the%20product.%20Examples%20of%20such%20waits%20are%20PAGEIOLATCH_SH%2C%20PAGEIOLATCH_EX%2C%20WRITELOG%2C%20IO_COMPLETION.%20If%20these%20waits%20exceed%2010-15%20ms%20on%20a%20consistent%20basis%2C%20then%20I%2FO%20is%20considered%20a%20bottleneck.%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSTRONG%3E%20The%20Methodology%20(updated%20in%20Jan%202019)%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20669px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F99157iDAF513F773F5AB4A%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Slow%20Disk%20IO%20T-shooting.jpg%22%20title%3D%22Slow%20Disk%20IO%20T-shooting.jpg%22%20%2F%3E%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CDIV%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSTRONG%3E%20Methodology%20Summary%3A%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CP%3EThe%20hope%20is%20that%20the%20flow%20chart%20above%20is%20self-explanatory%2C%20but%20here%20are%20some%20notes%20on%20it%20to%20provide%20guidance.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E1.%20Determine%20if%20there%20is%20I%2FO%20latency%20reported%20by%20SQL%20Server%20wait%20types.%20PAGEIOLATCH_*%20%2C%20WRITELOG%20values%20%2C%20as%20well%20as%20those%20of%20several%20other%20less%20common%20wait%20types%2C%20should%20generally%20stay%20below%2015-20%20milliseconds%20per%20I%2FO%20request.%20If%20these%20values%20are%20greater%20on%20a%20consistent%20basis%2C%20then%20a%20I%2FO%20performance%20problem%20exists%20and%20warrants%20further%20investigation.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E2.1%20If%20SQL%20Server%20reports%20I%2FO%20latency%2C%20then%20refer%20to%20OS%20counters.%20Determine%20if%20there%20is%20an%20I%2FO%20problem%2C%20by%20examining%20the%20latency%20counter%20-%20%3CSTRONG%3E%20Avg%20Disk%20Sec%2FTransfer.%20%3C%2FSTRONG%3E%20If%2C%20the%20values%20of%20this%20counter%20are%20consistently%20above%2015-20%20ms.%20then%20you%20need%20to%20take%20a%20look%20at%20the%20issue%20further.%20(Occasional%20spikes%20don't%20count%20in%20most%20cases%2C%20but%20be%20sure%20to%20double-check%20the%20duration%20of%20a%20spike%20-%20if%20it%20lasted%201%20minute%20or%20more%2C%20then%20it%20is%20more%20of%20a%20plateau%20than%20a%20spike.)%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E2.2%20If%20Performance%20monitor%20counters%20do%20not%20report%20latency%2C%20but%20SQL%20Server%20does%2C%20then%20the%20problem%20is%20%3CU%3Ebetween%3C%2FU%3E%20SQL%20Server%20and%20the%20Partition%20Manager%20(the%20I%2FO%20layer%20at%20which%20the%20OS%20collects%20Perfmon%20counters)%3B%20that%20is%20file%20system%20filter%20drivers.%20Ensuring%20proper%20exclusions%20of%20filter%20driver%20and%20resolving%20filter%20driver%20issues%20is%20the%20next%20logical%20step.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E3.%20If%20I%2FO%20subsystem%20is%20slow%2C%20then%20find%20out%20if%20that%20is%20caused%20by%20the%20system%20being%20overwhelmed%20beyond%20capacity%20by%20looking%20at%20I%2FO%20volumes%20-%20%3CSTRONG%3E%20Disk%20Bytes%2FSec%20%3C%2FSTRONG%3E%20or%20%3CSTRONG%3E%20Disk%20Read%26nbsp%3BBytes%2FSec%2C%20%3C%2FSTRONG%3E%20%3CSTRONG%3E%20Disk%20Write%20Bytes%2FSec%20%3C%2FSTRONG%3E%20.%20Be%20sure%20to%20check%20with%20your%20System%20Admin%20or%20hardware%20vendor%20on%20what%20the%20expected%20throughput%20specifications%20are%20for%20your%20SAN%20(or%20other%20I%2FO%20subsystem).%20For%20example%20you%20can%20only%20push%20no%20more%20than%20200%20MB%2Fsec%20of%20I%2FO%20through%20a%202%20Gb%2Fsec%20HBA%20card%20or%202%20Gb%2Fsec%20dedicated%20port%20on%20a%20SAN%20switch.%26nbsp%3B%20The%20expected%20throughput%20capacity%20defined%20by%20hardware%20manufacturer%20defines%20how%20you%20proceed%20from%20here.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E4.%20If%20I%2FO%20subsystem%20is%20overwhelmed%20beyond%20capacity%2C%20then%20find%20out%20if%20SQL%20Server%20is%20the%20culprit%20by%20looking%20at%20%3CSTRONG%3E%20Buffer%20Manager%3A%20Page%20Reads%2FSec%20%3C%2FSTRONG%3E%20(most%20common%20culprit)%20and%20%3CSTRONG%3E%20Page%20Writes%2FSec%20%3C%2FSTRONG%3E%20(a%20lot%20less%20common).%20If%20SQL%20Server%20is%20the%20main%20I%2FO%20driver%20and%20I%2FO%20volume%20is%20beyond%20what%20the%20system%20can%20handle%2C%20then%20you%20need%20to%20work%20with%20the%20Application%20Development%20teams%20(or%20application%20vendor)%20to%20tune%20queries%20-%20better%20indexes%2C%20update%20statistics%2C%20re-write%20queries%2C%20re-design%20the%20database%2C%20etc.%20Also%2C%20you%20can%20consider%20increasing%20max%20server%20memory%2C%20or%20adding%20more%20memory%20which%20will%20allow%20more%20data%2Findex%20pages%20to%20be%20cached%20and%20not%20re-read%20from%20disk%20frequently.%3C%2FP%3E%3CBR%20%2F%3E%3CSTRONG%3E%20Further%20Comments%3A%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CP%3EIn%20general%20there%20could%20be%20three%20high-level%20reasons%20why%20SQL%20Server%20queries%20suffer%20from%20I%2FO%20latency%3A%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E1.%20%3CSTRONG%3EHardware%20issues%3A%20%3C%2FSTRONG%3E%20There%20is%20a%20SAN%20misconfiguration%20(switch%2C%20cables%2C%20HBA%2C%20storage)%2C%20exceeded%20I%2FO%20capacity%20(throughout%20entire%20SAN%20network%2C%20not%20just%20back-end%20storage)%2C%20drivers%2Ffirmware%20bug%2C%20etc%20with%20the%20disk%20I%2FO%20subsystem%20and%20that%20is%20where%20the%20hardware%20vendor%20need%20to%20be%20engaged%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E2.%20%3CSTRONG%3EQuery%20Issues%3A%20%3C%2FSTRONG%3E%20SQL%20Server%20(or%20some%20other%20process%20in%20some%20cases)%20on%20the%20system%20is%20saturating%20the%20disks%20with%20I%2FO%20requests%20and%20that%20is%20why%20transfer%20rates%20are%20high.%20In%20this%20case%20we%20likely%20need%20to%20find%20queries%20that%20are%20driving%20tons%20of%20Reads%20(or%20writes)%20and%20tune%20them%20to%20minimize%20the%20disk%20I%2FO.%20Using%20appropriate%20indexes%20helps%2C%20as%20well%20as%20providing%20the%20optimizer%20sufficient%20information%20to%20choose%20the%20best%20plan%2C%20i.e.%20keep%20statistics%20updated.%20Also%20incorrect%20database%20design%20and%20query%20design%20lead%20to%20increase%20in%20I%2FO.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E3.%20%3CSTRONG%3EFilter%20Drivers%3A%20%3C%2FSTRONG%3E%20SQL%20Server%20I%2FO%20response%20can%20be%20severely%20impacted%20if%20file-system%20filter%20drivers%20which%20process%20the%20heavy%20I%2FO%20traffic.%20%3CA%20href%3D%22https%3A%2F%2Fsupport.microsoft.com%2Fen-us%2Fhelp%2F309422%2Fchoosing-antivirus-software-for-computers-that-run-sql-server%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EProper%20file%20exclusions%20%3C%2FA%3E%20and%20correct%20filter%20driver%20design%20is%20recommended%20to%20prevent%20this%20from%20happening.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ENamaste!%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EJoseph%3C%2FP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-333983%22%20slang%3D%22en-US%22%3E%3CP%3EFirst%20published%20on%20MSDN%20on%20Dec%2006%2C%202012%20This%20SQL%20meditation%20provides%20a%20general%20approach%20on%20how%20to%20troubleshoot%20SQL%20Server%20I%2FO%20related%20issues.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-333983%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPerformance%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EStorage%20Engine%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Etroubleshooting%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

First published on MSDN on Dec 06, 2012

This provides a general approach on how to troubleshoot SQL Server I/O-related issues. My belief is that if you truly understand this, you are empowered to solve the disk I/O challenges yourself.



Define slow disk performance:

 

The metric commonly used to measure slow I/O performance is the metric that measure how fast the I/O subsystem is servicing each I/O request on the average in terms of clock time. The specific Performance monitor counters that measure I/O latency in Windows are Avg Disk sec/ Read , Avg. Disk sec/Write and Avg. Disk sec/Transfer (cumulative of both reads and writes).

 

From a SQL Server perspective things are no different. We usually look at whether SQL Server reports any I/O bottlenecks measured in clock time (milliseconds). SQL Server makes I/O requests to the OS by calling Win32 functions - WriteFile(), ReadFile(), WriteFileGather(), ReadFileScatter(). When it posts an I/O requests, SQL Server times the request and reports how long that request took. SQL Server uses Wait Types to indicate I/O waits at different places in the product. Examples of such waits are PAGEIOLATCH_SH, PAGEIOLATCH_EX, WRITELOG, IO_COMPLETION. If these waits exceed 10-15 ms on a consistent basis, then I/O is considered a bottleneck.




The Methodology (updated in Jan 2019)
Slow Disk IO T-shooting.jpg











Methodology Summary:

The hope is that the flow chart above is self-explanatory, but here are some notes on it to provide guidance.


1. Determine if there is I/O latency reported by SQL Server wait types. PAGEIOLATCH_* , WRITELOG values , as well as those of several other less common wait types, should generally stay below 15-20 milliseconds per I/O request. If these values are greater on a consistent basis, then a I/O performance problem exists and warrants further investigation.


2.1 If SQL Server reports I/O latency, then refer to OS counters. Determine if there is an I/O problem, by examining the latency counter - Avg Disk Sec/Transfer. If, the values of this counter are consistently above 15-20 ms. then you need to take a look at the issue further. (Occasional spikes don't count in most cases, but be sure to double-check the duration of a spike - if it lasted 1 minute or more, then it is more of a plateau than a spike.)


2.2 If Performance monitor counters do not report latency, but SQL Server does, then the problem is between SQL Server and the Partition Manager (the I/O layer at which the OS collects Perfmon counters); that is file system filter drivers. Ensuring proper exclusions of filter driver and resolving filter driver issues is the next logical step.


3. If I/O subsystem is slow, then find out if that is caused by the system being overwhelmed beyond capacity by looking at I/O volumes - Disk Bytes/Sec or Disk Read Bytes/Sec, Disk Write Bytes/Sec . Be sure to check with your System Admin or hardware vendor on what the expected throughput specifications are for your SAN (or other I/O subsystem). For example you can only push no more than 200 MB/sec of I/O through a 2 Gb/sec HBA card or 2 Gb/sec dedicated port on a SAN switch.  The expected throughput capacity defined by hardware manufacturer defines how you proceed from here.


4. If I/O subsystem is overwhelmed beyond capacity, then find out if SQL Server is the culprit by looking at Buffer Manager: Page Reads/Sec (most common culprit) and Page Writes/Sec (a lot less common). If SQL Server is the main I/O driver and I/O volume is beyond what the system can handle, then you need to work with the Application Development teams (or application vendor) to tune queries - better indexes, update statistics, re-write queries, re-design the database, etc. Also, you can consider increasing max server memory, or adding more memory which will allow more data/index pages to be cached and not re-read from disk frequently.


Further Comments:

In general there could be three high-level reasons why SQL Server queries suffer from I/O latency:


1. Hardware issues: There is a SAN misconfiguration (switch, cables, HBA, storage), exceeded I/O capacity (throughout entire SAN network, not just back-end storage), drivers/firmware bug, etc with the disk I/O subsystem and that is where the hardware vendor need to be engaged


2. Query Issues: SQL Server (or some other process in some cases) on the system is saturating the disks with I/O requests and that is why transfer rates are high. In this case we likely need to find queries that are driving tons of Reads (or writes) and tune them to minimize the disk I/O. Using appropriate indexes helps, as well as providing the optimizer sufficient information to choose the best plan, i.e. keep statistics updated. Also incorrect database design and query design lead to increase in I/O.


3. Filter Drivers: SQL Server I/O response can be severely impacted if file-system filter drivers which process the heavy I/O traffic. Proper file exclusions and correct filter driver design is recommended to prevent this from happening.


Namaste!


Joseph