28
IO, IO! Why’s my SQL slow? Brian Flynn Product Manager © 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

How to fix IO problems for faster SQL Server performance

Embed Size (px)

Citation preview

Page 1: How to fix IO problems for faster SQL Server performance

IO, IO! Why’s my SQL slow?

Brian Flynn

Product Manager

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 2: How to fix IO problems for faster SQL Server performance

Define Speed?

» Acceleration

» Burst/Top Speed

» Sustained Speed

» Constraints

» Total Trip Time

» Average Speed

2

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 3: How to fix IO problems for faster SQL Server performance

» Imagine transporting things a long distance.

» Just you and an over night bag vs everything you own…

3

Latency, Speed, & Throughput

High Acceleration (Low Latency) Medium Acceleration (Medium Latency) Low Acceleration (High Latency)

High Top Speed Medium Top Speed Low Top Speed

Small Cargo Medium Cargo Large Cargo

Low Capacity Medium Capacity High Capacity

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 4: How to fix IO problems for faster SQL Server performance

Latency, Speed, & Throughput

» Electricity: Volts / Ohms = Amps

Volts * Amps = Watts

» Data: Buffer Size / Latency = Transfer Rate

Buffer Size * Transfer Rate = Throughput

4

Analogy Size Current Resistance Capacity

Electricity Volts Amps Ohms Watts

Water Pressure Flow Rate Inverse of channeldiameter

Volume/Time

Data Buffer Size* compression* jumbo frames

Transfer Rate

*IOPS

Latency* Function of Distance* Function of storage type

Throughput

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 5: How to fix IO problems for faster SQL Server performance

Latency, Speed, & Throughput

» When speed is constant, packet size governs throughput.

» Larger packets increase throughput.

» Greater distance increases latency which lowers perceivedthroughput.

5

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 6: How to fix IO problems for faster SQL Server performance

True speed is all about latency

» 1 byte or 1000 bytes,same trip time.

» Overhead accounts for more constraint than sum of the serialized trips.

6

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 7: How to fix IO problems for faster SQL Server performance

Aren’t we talking about storage?

» HDD latency Rotating the platter Moving the head

» SSD latency One controller is a gateway for multiple chips

» RAID latency Mirror – Improves read IOPS if split reads is supported. Stripe – Improves read & write IOPS. Distributed Parity – Write IOPS penalty for calculating parity bits. Raid 10 – Mirror & Stripe. No write penalty. Twice the price of stripe only.

» SAN latency One controller is the gateway to many disks. Limited bandwidth to arrays

» NAS latency Network is usually the weakest link

7

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 8: How to fix IO problems for faster SQL Server performance

Enough already, just make it faster!

» There’s more than straight line acceleration.

» Complex systems force us to tease out the latency bottlenecks

» Balancing 3 Options1. Get the same work done with fewer operations

2. Do more in parallel

3. Make individual operations faster

8

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 9: How to fix IO problems for faster SQL Server performance

Get the same work done with fewer operations

» In our transportation example, same work with fewer trips… The big semi does this… larger cargo or payload.

» With data, however… Eliminate redundant or superfluous database work

• Create indexes that reduce table scans• Keep tables defragmented to increase read-ahead• Keep frequently used data in application memory

Caching techniques to reduce re-reading from storage• SAN cache• Server memory• SQL 2014 Buffer Pool Extension

Compress data• More pages in memory increases page life expectancy• Compressed data will fit into fewer Physical I/Os• ** CPU latency must be lower than storage latency

9

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 10: How to fix IO problems for faster SQL Server performance

Do more in parallel

» Adding disks to an array increases maximum IOPS Helps where I/O can be parallelized

• Multiple CPU issuing synchronous I/Os• SQL Server Pre-fetch & Read-ahead• Reference: MSDN: Sequential Read Ahead

» Defragmentation increases Read-ahead, which is asynchronous» Evaluate for parallel capabilities end to end

Multiple file groups on isolated storage Multiple, isolated LUNs Multiple OS disk queues Consider SAN paths & controllers

» Bottom line, you can’t parallelize everything Business Analogy: The Mythical Man Month Humorous Analogy: The Pregnancy Problem

10

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 11: How to fix IO problems for faster SQL Server performance

Make individual operations faster

» Almost always, a winner! But often, the most expensive solution.

» Lower latency storage HDD Moving parts Mechanical latency

Random reads More mechanical latency

Thus to optimize, maximize sequential reads before random reads

Of course, with RAID arrays, almost every read is random

SSDs have no moving parts No mechanical latency

Thus all reads are equal. No benefit to sequential vs random

» Who’s IO are we talking about? Typical disk I/Os are usually 4K

SQL Server I/Os range from 8K to 512K

» REF: http://www.confio.com/logicalread/fragmentation-reorganization-rebuilds-sql-server-table-scans-bf01/#.U1aJKvldU9I

11

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 12: How to fix IO problems for faster SQL Server performance

How Do I Choose? It depends… :-\

» It depends… At best, all three. Next best, any combination. 3rd party software may not permit your query tuning

Budget constraints may not permit low latency storage

The size of I/Os may not lend to parallelizing workloads

» General rules: Reducing total # I/Os is always a winner.

For large result sets or concurrency Increasing IOPS can help a lot

For small result sets Raw speed (Latency) may be your only hope.

12

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 13: How to fix IO problems for faster SQL Server performance

Disk Queue Depth

» I hate queues, especially at the DMV! Waiting in line stinks!

» Disk Queue Length is a measure of I/O constraint.

» How high is OK? It depends on your environment. Different performance expectation between OLTP and OLAP systems

» If it’s consistently high, adding disks to the array may help.

» You should be watching this one and DPA does that…

13

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 14: How to fix IO problems for faster SQL Server performance

Other WMI Counters

» Latency-Like Avg. Disk Sec/Read is the average time, in seconds, of a read of data

from the disk.

Avg. Disk Sec/Write is the average time, in seconds, of a write of data to the disk.

» Current-Like Avg. Disk Reads/Sec is the rate of read operations on the disk.

Avg. Disk Writes/Sec is the rate of write operations on the disk.

» Physical Disk: %Disk Time is the percentage of elapsed time that the selected disk drive was busy servicing read or write requests.

REF: http://blogs.msdn.com/b/dpless/archive/2010/12/01/leveraging-sys-dm-io-virtual-file-stats.aspx?Redirected=true

14

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 15: How to fix IO problems for faster SQL Server performance

Virtual File Stats DMO

15

http://technet.microsoft.com/en-us/library/ms190326.aspx

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 16: How to fix IO problems for faster SQL Server performance

Crystal Disk Mark

» A great, free tool that tells you the throughput of your storage under a few mixtures of I/O size, queue depth and sequential or random I/O. You may not get your storage admin’s blessing to run this. But it’s a decent way to measure throughput.

16

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 17: How to fix IO problems for faster SQL Server performance

SQLIO

17

REF: http://www.brentozar.com/archive/2008/09/finding-your-san-bottlenecks-with-sqlio/

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 18: How to fix IO problems for faster SQL Server performance

18

Query Plans & Process Monitor

» Query plans tell you when you’re scanning and seeking

» ProcMon tells you how many and how big are the storage I/Os

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 19: How to fix IO problems for faster SQL Server performance

Server memory, SAN Cache, Tierd Storage etc

» You’ll have to clear a few obstacles.

» SQL Server caches pages in RAM so when testing you’ll need dump the buffer cache to ensure you are going to disk.

» And unless your storage admin is a gift from the DBA gods, you’ll have to get real creative to control for SAN cache in any experiments.

» Tiered storage can cause unpredictability too.

19

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 20: How to fix IO problems for faster SQL Server performance

Free Tools for SAN & VM environments

20

http://www.solarwinds.com/products/freetools/san_monitor/

http://www.solarwinds.com/products/freetools/storage-response-time-monitor.aspx

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 21: How to fix IO problems for faster SQL Server performance

Design Choices : Fragmentation Impacts

» Design for Read Ahead Understand & avoid physical and logical fragmentation

Clustered indexes that monotonously increment on isolated storage

Pre-allocate files in larger swatches rather than auto-grow

» Use file groups and different storage based on I/O demand Rarely accessed things on less performant media

Frequently accessed things on highly performant media

» Plan ahead!

21

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 22: How to fix IO problems for faster SQL Server performance

DMV Wait Types

» Multiple wait types indicate storage I/O

» DPA breaks down query execution by wait type over time. http://database.demo.solarwinds.com/

22

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 23: How to fix IO problems for faster SQL Server performance

DEMONSTRATION TIME!

23

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 24: How to fix IO problems for faster SQL Server performance

Think you have Database I/O issues?

» DPA can identify and recommend action on I/O issues.

» Check out the new Storage I/O feature in DPA 9.0!

24

http://www.solarwinds.com/resources/videos/utilize-dpa-storage-io-to-find-performance-issues.html

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 25: How to fix IO problems for faster SQL Server performance

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Quickly resolve Oracle performance issues

» Try Database Performance Analyzer FREE for 14 days

» Improve root cause of slow performance Identify issues that impact end-user response time

Isolates root cause in just four clicks

See historical trends over days, months, and years

Understand impact of VMware® performance

Agentless architecture with no dependence on Oracle Packs, installs in minutes

www.solarwinds.com/dpa-download/

Page 26: How to fix IO problems for faster SQL Server performance

Thank you!

» Brian Flynn

» [email protected]

» Twitter : @brianpaulflynn

» LinkedIn: brianpaulflynn

26

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 27: How to fix IO problems for faster SQL Server performance

Questions?

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Page 28: How to fix IO problems for faster SQL Server performance

© 2014 SOLARWINDS WORLDWIDE, LLC. ALL RIGHTS RESERVED.

Thank You!

The SOLARWINDS and SOLARWINDS & Design marks are the exclusive property of SolarWinds Worldwide, LLC, are registered with the U.S.

Patent and Trademark Office, and may be registered or pending registration in other countries. All other SolarWinds trademarks, service

marks, and logos may be common law marks, registered or pending registration in the United States or in other countries. All other

trademarks mentioned herein are used for identification purposes only and may be or are trademarks or registered trademarks of their respective

companies.