The Art of SQL Server Performance Tuning



Similar documents
SQL Server Performance Tuning and Optimization

Microsoft SQL Server: MS Performance Tuning and Optimization Digital

MS SQL Performance (Tuning) Best Practices:

About Me: Brent Ozar. Perfmon and Profiler 101

Best Practices for Deploying SSDs in a Microsoft SQL Server 2008 OLTP Environment with Dell EqualLogic PS-Series Arrays

Maximizing SQL Server Virtualization Performance

NIMSOFT SLM DATABASE

IncidentMonitor Server Specification Datasheet

Analysis of VDI Storage Performance During Bootstorm

Azure VM Performance Considerations Running SQL Server

Enhancing SQL Server Performance

One of the database administrators

Deploying and Optimizing SQL Server for Virtual Machines

Solving Performance Problems In SQL Server by Michal Tinthofer

Virtuoso and Database Scalability

Best Practices for Monitoring Databases on VMware. Dean Richards Senior DBA, Confio Software

Evaluation Report: Accelerating SQL Server Database Performance with the Lenovo Storage S3200 SAN Array

Optimizing Performance. Training Division New Delhi

SQL Server 2012 Optimization, Performance Tuning and Troubleshooting

XenDesktop 7 Database Sizing

Query Performance Tuning: Start to Finish. Grant Fritchey

HP ProLiant DL580 Gen8 and HP LE PCIe Workload WHITE PAPER Accelerator 90TB Microsoft SQL Server Data Warehouse Fast Track Reference Architecture

Distribution One Server Requirements

SQL Server 2014 New Features/In- Memory Store. Juergen Thomas Microsoft Corporation

StreamServe Persuasion SP5 Microsoft SQL Server

Dynamics NAV/SQL Server Configuration Recommendations

Virtualisa)on* and SAN Basics for DBAs. *See, I used the S instead of the zed. I m pretty smart for a foreigner.

SQL Server Version. Supported for SC2012 RTM*** Not supported for SC2012 SP1*** SQL Server 2008 SP1, SP2, SP3

AE EHR Database Servers

VirtualCenter Database Performance for Microsoft SQL Server 2005 VirtualCenter 2.5

Microsoft SQL Server performance tuning for Microsoft Dynamics NAV

SQL Server 2008 Designing, Optimizing, and Maintaining a Database Session 1

PARALLELS CLOUD STORAGE

Oracle Rdb Performance Management Guide

Performance Tuning and Optimizing SQL Databases 2016

WHITE PAPER. SQL Server License Reduction with PernixData FVP Software

Condusiv s V-locity Server Boosts Performance of SQL Server 2012 by 55%

Summary: This paper examines the performance of an XtremIO All Flash array in an I/O intensive BI environment.

Managing Orion Performance

XTM Web 2.0 Enterprise Architecture Hardware Implementation Guidelines. A.Zydroń 18 April Page 1 of 12

PERFORMANCE TUNING IN MICROSOFT SQL SERVER DBMS

DIABLO TECHNOLOGIES MEMORY CHANNEL STORAGE AND VMWARE VIRTUAL SAN : VDI ACCELERATION

Disk Storage Shortfall

Preparing a SQL Server for EmpowerID installation

Capacity Planning for Microsoft SharePoint Technologies

MS SQL Server 2014 New Features and Database Administration

MS EXCHANGE SERVER ACCELERATION IN VMWARE ENVIRONMENTS WITH SANRAD VXL

Accelerating Server Storage Performance on Lenovo ThinkServer

Q & A From Hitachi Data Systems WebTech Presentation:

Throughput Capacity Planning and Application Saturation

Performance rule violations usually result in increased CPU or I/O, time to fix the mistake, and ultimately, a cost to the business unit.

Oracle DBA Course Contents

Solid State Storage in Massive Data Environments Erik Eyberg

Implementing EMC CLARiiON CX4 with Enterprise Flash Drives for Microsoft SQL Server 2008 Databases

Data Compression in Blackbaud CRM Databases

Performance Monitoring AlwaysOn Availability Groups. Anthony E. Nocentino

Deploying Affordable, High Performance Hybrid Flash Storage for Clustered SQL Server

WHITE PAPER Optimizing Virtual Platform Disk Performance

SQL Server Virtualization

Kronos Workforce Central on VMware Virtual Infrastructure

The 5-minute SQL Server Health Check

Introduction Disks RAID Tertiary storage. Mass Storage. CMSC 412, University of Maryland. Guest lecturer: David Hovemeyer.

SQL Best Practices for SharePoint admins, the reluctant DBA. ITP324 Todd Klindt

Best Practices for Optimizing SQL Server Database Performance with the LSI WarpDrive Acceleration Card

An Oracle White Paper July Oracle Primavera Contract Management, Business Intelligence Publisher Edition-Sizing Guide

Disks and RAID. Profs. Bracy and Van Renesse. based on slides by Prof. Sirer

Top 10 reasons your ecommerce site will fail during peak periods

BENCHMARKING CLOUD DATABASES CASE STUDY on HBASE, HADOOP and CASSANDRA USING YCSB

Virtualizing Microsoft SQL Server on Dell XC Series Web-scale Converged Appliances Powered by Nutanix Software. Dell XC Series Tech Note

Cloud Storage. Parallels. Performance Benchmark Results. White Paper.

Throwing Hardware at SQL Server Performance problems?

Performance White Paper

W I S E. SQL Server 2008/2008 R2 Advanced DBA Performance & WISE LTD.

Top 10 Performance Tips for OBI-EE

Big Fast Data Hadoop acceleration with Flash. June 2013

A Performance Engineering Story

SQL Server. SQL Server 100 Most Asked Questions: Best Practices guide to managing, mining, building and developing SQL Server databases

SQL Server Business Intelligence on HP ProLiant DL785 Server

PERFORMANCE TUNING FOR PEOPLESOFT APPLICATIONS

SharePoint 2010 Performance and Capacity Planning Best Practices

SQL Server Storage: The Terabyte Level. Brent Ozar, Microsoft Certified Master, MVP Consultant & Trainer, SQLskills.com

BridgeWays Management Pack for VMware ESX

Evaluation Report: Supporting Microsoft Exchange on the Lenovo S3200 Hybrid Array

Guerrilla Warfare? Guerrilla Tactics - Performance Testing MS SQL Server Applications

HP ProLiant Gen8 vs Gen9 Server Blades on Data Warehouse Workloads

Best Practices for Optimizing Storage for Oracle Automatic Storage Management with Oracle FS1 Series Storage ORACLE WHITE PAPER JANUARY 2015

Explain how to prepare the hardware and other resources necessary to install SQL Server. Install SQL Server. Manage and configure SQL Server.

Database Maintenance Essentials

EMC XTREMIO EXECUTIVE OVERVIEW

Microsoft SQL Server 2000 Index Defragmentation Best Practices

ESSENTIAL SKILLS FOR SQL SERVER DBAS

A Comparison of Oracle Performance on Physical and VMware Servers

Server 2008 SQL. Administration in Action ROD COLLEDGE MANNING. Greenwich. (74 w. long.)

A Comparison of Oracle Performance on Physical and VMware Servers

MOC 20462C: Administering Microsoft SQL Server Databases

SQL Server Performance Tuning for DBAs

File System & Device Drive. Overview of Mass Storage Structure. Moving head Disk Mechanism. HDD Pictures 11/13/2014. CS341: Operating System

Transcription:

The Art of SQL Server Performance Tuning Greg Linwood Managing Director MyDBA http://facebook.com\greglinwood

About Greg Linwood Founder of MyDBA Pty Ltd (2002) Microsoft s first SQL Server MVP Australian awardee (2003) https://mvp.support.microsoft.com/profile/greg.linwood Founder of the Australian SQL Server User Group (2004) www.sqlserver.org.au Working with SQL Server since 1993

Agenda Why do we still need to optimize databases? Things we can see, others we can t Reading between the lines Important aspects of: Database Tuning Infrastructure Tuning

Why we still need to optimize databases?(1 of 5) 1 st, because things change.. Code changes (releases, upgrades) Data changes (db growth, data patterns) Usage patterns change (users do things) Full implications of changes are rarely accounted for by developers (often impossible) Load testing is intrinsically hard (lack of toolset)

Why we still need to optimize databases?(2 of 5) 2 nd because query optimization is imprecise SQL is declarative not imperative CSS & RegEx are also declarative, C#, VB, Java etc imperative Returns CustID, OrderID & OrderDate for orders > 1st Jan 2005 No processing rules included in SQL statement, just the set of data to be returned Optimization often / sometimes goes wrong it can only work with indexes that exist.. sometimes queries are just too complex

Why we still need to optimize databases?(3 of 5) 2 nd because query optimization is imprecise (cont) Huge number of possible query plans available for complex queries Optimization is purely statistically based Sometimes optimizer has to guess in complex situations Lack of precision leads to inconsistency Parameter driven ( parameter sniffing )

Why we still need to optimize databases?(3 of 5) 3 rd, underlying technologies are inefficient Rotating disk drives are mechanical, not electronic Huge consequences RAID, battery caching Can be eliminated with SSDs Dependence on RAM caching to avoid HDD issues Dependence on aging algorithms to avoid caching issues Virtualization introduces new levels of inefficiency SQL OS within Windows OS within VM OS.. Layer upon layer upon layer of resource mgmt

Things we can see, others we can t (1 of 5) Things we CAN easily see CPU utilisation Taskman, Perfmon Yep, that s about all that s EASY to see

Things we can see, others we can t (2 of 5) Things we CAN T easily see Code / structure changes DDL Trigger / Event Notifications are options on SQL 2005+ Changing query plans No SQL Server feature to track this crucial metric yet Not just query plans, but query performance stats in general Requires manual trace capture / analysis or DMV polling Missing indexes DMVs are beginning to improve things, though unreliable and present recommendations for individual queries without considering wider workload

Things we can see, others we can t (3 of 5) Things we CAN T easily see (cont) Memory performance SQL Server uses RAM very differently to most apps SQL OS intelligently uses as much RAM as possible (whatever s available) to cache frequently accessed data, to avoid I/O as much as possible Requires analysis of internal SQLOS memory managers Page Life Expectancy is the best generic perfmon counter SQL Server:Buffer Manager\Page Life Expectancy Storage I/O performance I/O requests get queued, then cached at RAID controller Confuses analysis measuring queue depth isn t enough SQL Server Virtual File Stats provides waits analysis, full picture Requires manual scripting

Things we can see, others we can t (4 of 5) Things we CAN T easily see (cont) Physical Database Fragmentation Page Splitting System-wide perfmon counter available SQL Server:Access Methods\Page Splits/sec No-where near detailed enough, index level required There s no way of monitoring which indexes are fragmenting Leads to generic index maintenance practises Scanning indexes / defragging or rebuilding all indexes Deadlocking / Blocking SQLTrace events are available, but provide confusing information Deadlocking still best performed through trace flag 1204

Reading between the lines (1 of 5) High CPU consumption is usually an effect Usually the result of query plan inefficiency Very often lack of ideal indexes, sometimes poor compilation Sufficient CPU resources still necessary of course Determined by number of peak concurrent queries Query plan inefficiency also usually an effect Lack of ideal indexes a TRUE CAUSE Maybe poor compilation a rarer TRUE CAUSE Sometimes excessive SQL, TVFs, cursors

Reading between the lines (2 of 5) High memory consumption is by design SQL Server is designed to consume as much RAM as possible Cache as much data as possible to relieve disk I/O Cache as many query plans as possible to relieve compilations Very different from most other applications Controlled by SQL Server Operating System Fundamentally incompatible with Virtualization resource management I/O performance analysis requires reading layers O/S queues I/O requests Storage controller caches I/O requests HDDs experience latency during spindle rotation SQLOS waits for overall I/O request SQLOS measure only available at FILE level

Query Tuning (1 of 3) Splitting single huge queries Queries with too many tables joined require complex optimization, which is often done inconsistently Can be controlled by breaking into smaller query units, using temp tables to combine results Forces processing consistency, sometimes at slight performance trade-off. Don t always do this with complex queries, just with those that compile inconsistently & can t be easily hinted

Query Tuning (2 of 3) Query Hints Don t be afraid to use hints! WITH (INDEX = ) For when you want a specific index used WITH (MERGE, HASH, LOOPS JOIN) For when you want a specific join operator OPTION (FORCE ORDER) When you have ordered the tables specifically in SQL syntax for processing rules

Query Tuning (3 of 3) Splitting queries that use innocent little ORs OR is often better implemented with separate queries Particularly for flexible searching queries where a Stored Procedure is used & user chooses from optional parameters Separated query output can be piped to temp tables & requeried at the end of SP, or simply UNIONED together. Consider dynamic SQL multiple plans Modularization with Table Valued Functions SQL Server s query optimiser doesn t flatten out or fold query plans from TVFs into that of the calling query. Leads to massive inefficiencies eg a query that returns 1000 rows & refers to a TVF in select list, will call that TVF individually 1000 times

Physical Tuning (1 of 2) Indexing Good indexes are THE most crucial aspect of tuning SQL Server There are no universal rules, however: Generally use Clustered Indexes Especially if only index per table Sequential, narrow keys are ideal Natural / random keys tend to increase splitting Generally index columns referred to in foreign keys Beyond these basics, always look at indexing as a database or workload specific activity.

Physical Tuning (2 of 2) Filegroup / File placement Separate large databases into discrete filegroups Place large, intensely accessed tables onto separate FGs Allows discrete measurement of Virtual File Stats Always separate Tlogs from data files in storage Not just on separate volumes, must be physically seperated Less of an issue with SSDs, BUT Tlogs better on battery backed cache than SSDs anyway

Infrastructure Tuning (1 of 5) CPU # of CPUs required depends on # of concurrent queries Current Intel options: 6 core + HT (12 threads) @ 3.6Ghz (Xeon 5xxx) 8 core + HT (16 threads) @ 2.4Ghz (Xeon 7xxx) 10 core + HT (20 threads) @ 2.6Ghz (E7 8xxx) Choice depends on # of concurrent queries Fewer, faster threads for larger reporting workloads More, slower threads for highly concurrent workloads

Infrastructure Tuning (2 of 5) Memory Critical to cache workload away from disk I/O The slower your storage, the more Memory you need SANs, Virtualization particularly sensitive The more RAM, the better But no point provisioning substantially more RAM than DB sizes Other than to cater for future growth Current market price is ~AUD$9k for 256GB RAM is getting cheaper Versions & Editions of SQL Server & Windows define RAM limits Note SQL 2008 R2 Std Edn has new 64GB limit SQL OS manages RAM in a way that VMWare/ HyperV can t see Therefore, you can t rely on virtualization to dynamically manage memory this concept doesn t apply to SQL, due to SQLOS

Infrastructure Tuning (3 of 5) Storage HDDs Physical Spindles The more, faster, smaller spindles in arrays the better RAID 1+0 (mirroring + striping) faster than RAID 5 (parity) Write speeds significantly different, read speeds similar RAID 1+0 loses half of capacity for mirroring RAID 5 loses N-1 for parity RAID Controller Cache important (always battery backed) Set for read or write oriented depending on workload Remember, reads are synchronous, writes asynch

Infrastructure Tuning (4 of 5) Storage SSDs Solid State Drives No moving parts Massively faster Massively cheaper (for performance / capacity) Important to Over-provision Format to 75% of capacity for moderate write workloads Format to 50% of capacity for intense write workloads Keeps garbage collection from backing SSD device back into write cliff scenario Tlogs should not be on SSDs Still better on battery backed RAID controller cache TempDB data file is a primary candidate for SSD (no risk)

Infrastructure Tuning (5 of 5) Virtualization? Never a good idea for intense SQL workloads Beyond empirical overhead from extra host O/S layer Anywhere from 1% to 100% overhead Confusion during troubleshooting accounts for far more overhead than any empirical overhead. Trouble-shooting requires co-operation between VM admin & DBA, also often with SAN admin & very often these parties have competing agendas. Delays troubleshooting, extends downtime Virtualization really only appropriate for small scale, performance insensitive systems. Benefits are all IT maintenance, users bear perf consequences