This document is provided for informational purposes only and Microsoft makes no warranties, either express or implied, in this document. Information in this document, including URL and other Internet Web site references, is subject to change without notice. The entire risk of the use or the results from the use of this document remains with the user. Unless otherwise noted, the companies, organizations, products, domain names, addresses, logos, people, places, and events depicted in examples herein are fictitious. No association with any real company, organization, product, domain name, address, logo, person, place, or event is intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property. © 2013 Microsoft Corporation. All rights reserved. Microsoft and other Microsoft products referenced herein are trademarks of the Microsoft group of companies. All other trademarks are property of their respective owners. Disclaimer
PSSDiag SQL Nexus
What does it collect? Server Configuration PerfStats Script Event Logs Performance Monitor Profiler Trace Error Logs
It’s all about the bottleneck
Look for high number of logical reads Could be heavy compiles Could be stale statistics Find the most expensive query
What can I do? Enable Optimize for Adhoc Workloads Parameterization: Forced
Look for scans, hashes, sorts or expensive operators in plan Look for high number of logical reads Could be heavy compiles Find the most expensive query Incorrect cardinality estimation a top issue Missing indexes or out of date stats May be a query design issue Parallel queries may take over the machine Common issues Tune indexes, stats, and/or query Limiting MAXDOP for parallel queries is temporary Apply a hotfix build Parameterize the query to reduce compiles Common Solutions What if I don’t have high CPU?
Is it waiting on another resource? Is it idle? Is it running? Find the lead blocker Transaction not committed or long running transaction Waiting on another resource Poor query plan Basic concurrency is “working” Common issues Tune index, stats, and/or query Application design (Ex. Fix commit tran problem) Consider READ_COMMITTED_SNAPSHOT db option Typical Solutions Deadlocks start as blocking. Almost always app problem. A large blocking chain can lead to a “hang” as seen in ERRORLOG What if I don’t have blocking?
Turtle
High Sec/T + High Bytes/Sec = SQL Flood High Sec/T + High Bytes/Sec = SQL Flood High Sec/T + Low Bytes/Sec = Disk Subsystem High Sec/T + Low Bytes/Sec = Disk Subsystem
This is starting to sound familiar…
Not enough cache for data Physical read counters Buffer Cache Hit Ratio is misleading Check ‘max server memory’ Memory throttles lead to blocking Compile memory Query memory (sorts and hash joins) Not enough cache for queries Engine has forced limits Too many ad-hoc queries Check compilations/sec
DMVs, sp_updatestats, UPDATE STATS, and “auto stats” Update Stats DMVs, SHOWPLAN, and DTA Create missing indexes Change T-SQL, Query Hints, Plan Guides Change query Tune index, stats, query Change application Often required for blocking/deadlocks Tune hardware CPU, Memory, I/O Don’t just jump to any of these!
Test 5GB No kitchen sink
Use Showplan All for queries that never complete
Only run a heavy trace for a few minutes
True or False?
PSSdiag /B 14:00:00 PSSdiag /E +02:00:00 PSSdiag /B 08:00:00 /E +09:00:00 PSSdiag /E 02:00:00 /L /Q All command line parameters:
Is it SQL Server? Running (High CPU)? Find the most expensive query Missing indexes/stats or “stale” stats? Plan look “poor”? Cardinality Estimation Problems? Waiting? Locks (Blocking) I/O Network Other Latch Other Wait It’s all about the bottleneck SQL Server Wide Configuration rarely is the cause