Query Tuning for Database Pros & DevelopersTed Krueger
The Developer and DBA Affair• Ownership – Database Ownership – Server Ownership – Code Ownership • Functional working relationships• SQL Server Performance vs. Database Performance – Tuning T-SQL at the code level – Developer with DBA Assistance – Hardware Tuning – DBA with Developer Assistance
My T-SQL is so bad your…. – Start here Developers • Middle DBA/Code Review They should know the internals and performance reasoning and make suggestions. i.e. so why is SELECT * – End here Developers
My DBA is so bad your…• Every role has an apple• DBA roles aren’t bad ones – Making relationships where it counts • Hardware Upgrades • Security Rights – VIEW SERVER STATE and VIEW DATABASE STATE • Work Together!
Monitor – Talk DBA to me• Active Monitoring – Blocking • Code practices resulting in blocking • Proactive tuning – Deadlocks • #1 reason for deadlocking – Poor performance of T-SQL – Timeouts • Unhappy – Oh how long is that query running? • Event Notifications • Extended Events • Blocked Process Reports
Tuning - #1 Most Effective AreaQuery Optimization Processor Parsing Algebrizer Optimizer Tree
How SELECT is read GROUP FROM JOIN WHERE HAVING SELECT SORTS BY
Think “Result Set” not like a developer• Data is served not conditioned• Business Rules apply to the business layer not the data• Procedure <> Procedural• Row based operations are for high-level languages – Serve applications data – they do the work – Minimize the data being sent and received