Aaron Bertrand SQL Sentry, Senior Kevin Kline SQL Sentry, Dir of Engineering

Slides:



Advertisements
Similar presentations
TWO STEP EQUATIONS 1. SOLVE FOR X 2. DO THE ADDITION STEP FIRST
Advertisements

Chapter 1 The Study of Body Function Image PowerPoint
1 Copyright © 2013 Elsevier Inc. All rights reserved. Appendix 01.
1 Copyright © 2010, Elsevier Inc. All rights Reserved Fig 2.1 Chapter 2.
1 Copyright © 2013 Elsevier Inc. All rights reserved. Chapter 38.
By D. Fisher Geometric Transformations. Reflection, Rotation, or Translation 1.
Chapter 1 Image Slides Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Business Transaction Management Software for Application Coordination 1 Business Processes and Coordination.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Title Subtitle.
0 - 0.
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
ADDING INTEGERS 1. POS. + POS. = POS. 2. NEG. + NEG. = NEG. 3. POS. + NEG. OR NEG. + POS. SUBTRACT TAKE SIGN OF BIGGER ABSOLUTE VALUE.
MULT. INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
Addition Facts
ZMQS ZMQS
Haas MFE SAS Workshop Lecture 3:
BT Wholesale October Creating your own telephone network WHOLESALE CALLS LINE ASSOCIATED.
Report Card P Only 4 files are exported in SAMS, but there are at least 7 tables could be exported in WebSAMS. Report Card P contains 4 functions: Extract,
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Introduction to SQL Tuning Brown Bag Three essential concepts.
Overview of performance tuning strategies Oracle Performance Tuning Allan Young June 2008.
Database Performance Tuning and Query Optimization
Yavapai College Self Service Banner Training. Agenda Definition of Key Concepts Log Into Finance Self Service Budget Query Overview Budget Query Procedures.
ABC Technology Project
Top Tuning Tools for SQL Server Kevin Kline & Aaron Bertrand SQL Sentry.
1 Web-Enabled Decision Support Systems Access Introduction: Touring Access Prof. Name Position (123) University Name.
Chapter 7 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi.
Yong Choi School of Business CSU, Bakersfield
Displaying Data from Multiple Tables
Go-Faster Consultancy Ltd.1 Experiences of Global Temporary Tables in Oracle 8.1 David Kurtz Go-Faster Consultancy Ltd.
Review Chapter 11 - Tables © 2010, 2006 South-Western, Cengage Learning.
Creating Tables. 2 home back first prev next last What Will I Learn? List and provide an example of each of the number, character, and date data types.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 12 – Security Panel Application Introducing.
© S Haughton more than 3?
VOORBLAD.
8 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Using Explicit Cursors.
Note: A bolded number or letter refers to an entire lesson or appendix. A Adding Data Through a View ADD_MONTHS Function 03-22, 03-23, 03-46,
Squares and Square Root WALK. Solve each problem REVIEW:
SIMOCODE-DP Software.
GG Consulting, LLC I-SUITE. Source: TEA SHARS Frequently asked questions 2.
Aaron Bertrand SQL Sentry, Senior Kevin Kline SQL Sentry, Dir of Engineering
Aaron Bertrand SQL Sentry, Senior Kevin Kline SQL Sentry, Dir of Engineering
Addition 1’s to 20.
25 seconds left…...
Januar MDMDFSSMDMDFSSS
Week 1.
We will resume in: 25 Minutes.
1 Unit 1 Kinematics Chapter 1 Day
How Cells Obtain Energy from Food
Use the tools support uses.
SQL Performance 2011/12 Joe Chang, SolidQ
Every SQL Programmer Should Know Kevin Kline Director of Engineering Services at SQL Sentry Microsoft MVP since 2003 Facebook, LinkedIn, Twitter at KEKLINE.
T-SQL : Bad Habits to Kick Aaron Bertrand SQL Sentry, Inc.
How to kill SQL Server Performance Håkan Winther.
Scott Fallen Sales Engineer, SQL Sentry Blog: scottfallen.blogspot.com.
Kevin Kline Director of Engineering Services, SQL Sentry SQL Server MVP since 2003 Twitter, FB, LI: KEKline Blog:
Crash course on Better SQL Development
The Killing Cursors Cyndi Johnson
Query Optimization Techniques
Crash course on Better SQL Development
Crash course on Better SQL Development
Crash course on Better SQL Development
SQL Server Query Design and Optimization Recommendations
Query Optimization Techniques
Presentation transcript:

Aaron Bertrand SQL Sentry, Senior Kevin Kline SQL Sentry, Dir of Engineering

Check for links to the video, slides, and demo code starting August 1st.

Drawing on July 31 st for a chance to win one of 3 Rookie Experience packages and 3 Ride Along packages from the Richard Petty Driving Experience at Charlotte Motor Speedway on October 18, 2013.

Introductions Patterns & Anti-Patterns o Efficient ad hoc sets (Aaron) o Best practices for comma-delimited parameters (Aaron) o Implicit Conversions (Kevin) o Best practices in temporary structures (Kevin) Follow Up

13.Specifying the schema 14.SP_xyz Prefix 15.Unwanted recompiles 16.The “Kitchen Sink” stored procedure 17.SP_ExecuteSQL vs EXEC(…) 18.Execution Plan Self-Destruct 19.To MERGE or not to MERGE 20.Efficient ad hoc sets 21.Implicit conversions 22.Best practices for comma-delimited parameters 23.Best practices in temporary structures 1.Bad, Naughty Default Cursors 2.Correlated Subqueries 3.WHERE IN versus WHERE EXISTS 4.UNION versus UNION ALL 5.WHERE {NOT IN | EXISTS} versus LEFT JOIN 6.Queries optimized for SELECT but not DML statements 7.Compound index columns 8.Covering indexes 9.The Transitive Property 10.Queries with IN (…) or OR 11.Queries with wildcard searches 12.Using functions in WHERE or JOIN clauses

Example: a set of days in a range Recursive CTEs can do this, but… Create a permanent number/calendar table instead DEMO

SQL Server has to do a lot of extra work / scans when conversion operations are assumed by the SQL programmer. Happens all the time with data types you’d think wouldn’t need it, e.g. between date types and character types. Very useful data type conversion chart at Data type precedence call also have an impact: DEMO

Ian Stirk’s Column Mismatch Utility at Jonathan Kehayias’ plan cache analyzer at implicit-column-conversions-in-the-plan-cache.aspx. implicit-column-conversions-in-the-plan-cache.aspx Jonathan Kehayias’ index scan study at index-scans/ index-scans/

Example: pass a comma-separated list of OrderIDs String splitting is expensive, even using CLR Table-valued parameters are typically a better approach DEMO

Which are better, temp tables or temp variables? Temp TableTemp Variable Stored in?Tempdb Statistics?YesNo (1 row) Indexs/Keys?Yes1 UK / PK only Truncate?YesNo Recompiles?YesNo Parallelism?YesNo Metadata Overhead?LowLowest Lock Overhead?NormalLowest

Comma-delimited parameters may be better with TVPs than splitting strings. Implicit conversions can cause extra CPU work and/or index and table scans. Efficient ad hoc sets may not be best in recursive CTEs. Test your alternatives. Temporary tables and temporary variable each have their uses. Know when to use each.

1.Engage with our community: SQL Sentry on Facebook, SQLSentry.Net, SQLPerformance.com 2.Share your tough query problems with us: Download SQL Sentry Plan Explorer for free: Check out our other award winning tools: