Query Tuning for Database Pros & Developers
Upcoming SlideShare
Loading in...5
×
 

Query Tuning for Database Pros & Developers

on

  • 680 views

Presentation for Code Mastery-Chicago.

Presentation for Code Mastery-Chicago.
Ted Krueger, Associate Principal Consultant, Microsoft MVP

Statistics

Views

Total Views
680
Views on SlideShare
441
Embed Views
239

Actions

Likes
0
Downloads
3
Comments
0

1 Embed 239

http://codemastery.com 239

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Query Tuning for Database Pros & Developers Query Tuning for Database Pros & Developers Presentation Transcript

  • 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
  • Execution Plans Scan / SeekOperations Join Sort Execution Plan Lookup Parallelism Convert
  • Start Tuning – High Cost Operations
  • 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
  • Lookup – RID and Key – The other loop
  • Preventive T-SQL• Conversions – CONVERT_IMPLICIT• Tempdb – Sort and spills from memory• Sargable – Taking advantage of indexing in predicates
  • Abusive tempdb usage• Estimation of memory results in more needs• Statistics forcing poor Hash Joins• Sorting large amounts of data
  • Find pre-existing badness• Querying the Plan Cache – DMV and DMF • sys.dm_exec_cached_plans • sys.dm_exec_sql_text • sys.dm_exec_query_plan
  • Size Matters – Columns, Tables…Indexes • Column Length and Type • Duplicates • Overall Table Width • Overlapping • Page Count • Too Many • Overflow Page – All leading to transactional performance issues • DML suffers • UPDATE • DELETE • INSERT
  • Index Analysis – Repeat after me! • Duplicates • Overlapping • Too Many – All leading to transactional performance issues • DML suffers • UPDATE • DELETE • INSERT
  • ted@onpnt.comThank you! http://Twitter.com/onpntwww.magenic.com http://blogs.lessthandot.com