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

Slides:



Advertisements
Similar presentations
Enhancing Productivity with MySQL 5.6 New Features
Advertisements

Advanced SQL Topics Edward Wu.
Slide 1 Insert your own content. Slide 2 Insert your own content.
Yukon – What is New Rajesh Gala. Yukon – What is new.NET Framework Programming Data Types Exception Handling Batches Databases Database Engine Administration.
Haas MFE SAS Workshop Lecture 3:
Simplified Management using the Enterprise Policy Management Framework
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Presenter: Red Devilic Sponsored by SQLViet.com 22/12/2013 SQL SERVER CONFERENCE HCMC 2013 DATABASE TUNING PERFORMANCE OVERVIEW.
By: Jose Chinchilla July 31, Jose Chinchilla MCITP: SQL Server 2008, Database Administrator MCTS: SQL Server 2005/2008, Business Intelligence DBA.
Flex Your APEX Implementing Oracle E-Business Suite Descriptive Flexfields in Application Express Shane Bentz InterVarsity Christian Fellowship/USA.
Top Tuning Tools for SQL Server Kevin Kline & Aaron Bertrand SQL Sentry.
© Abdou Illia MIS Spring 2014
new database engine component fully integrated into SQL Server 2014 optimized for OLTP workloads accessing memory resident data achive improvements.
Chapter 7 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi.
1 Quick recap of the SQL & the GUI way in Management Studio The Adwentureworks database from the book A script to create tables & insert data for the Amazon.
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.
PL/SQL.
4 Oracle Data Integrator First Project – Simple Transformations: One source, one target 3-1.
1 Başar Öztayşi 2011 END 213E Data Processing in Industrial Systems SQL Structured Query Language.
Aaron Bertrand SQL Sentry, Senior Kevin Kline SQL Sentry, Dir of Engineering
Aaron Bertrand SQL Sentry, Senior Kevin Kline SQL Sentry, Dir of Engineering
Basic SQL Introduction Presented by: Madhuri Bhogadi.
1 SQL Server Management Studio SQL DDL CREATE TABLE Constraints ALTER TABLE DROP TABLE The GUI way Steen Jensen, autumn 2013.
Every SQL Programmer Should Know Kevin Kline Director of Engineering Services at SQL Sentry Microsoft MVP since 2003 Facebook, LinkedIn, Twitter at KEKLINE.
Introduction to Structured Query Language (SQL)
Module 9: Implementing Stored Procedures. Introduction to Stored Procedures Creating Executing Modifying Dropping Using Parameters in Stored Procedures.
CPSC-608 Database Systems Fall 2011 Instructor: Jianer Chen Office: HRBB 315C Phone: Notes #6.
Auditing Database DDL Changes with SQLVer. About PASS The PASS community encompasses everyone who uses the Microsoft SQL Server or Business Intelligence.
CPSC-608 Database Systems Fall 2010 Instructor: Jianer Chen Office: HRBB 315C Phone: Notes #6.
SQL Basics. SQL SQL (Structured Query Language) is a special-purpose programming language designed from managing data in relational database management.
Database Design for DNN Developers Sebastian Leupold.
Kevin Kline, SQL Sentry Director of Engineering Services, Microsoft SQL Server MVP since 2003 Twitter, Facebook, KEKline.
T-SQL : Bad Habits to Kick Aaron Bertrand SQL Sentry, Inc.
Database Technical Session By: Prof. Adarsh Patel.
Atlanta SQL Server Users Group April 10, 2006 Stored Procedure Best Practices Kevin Kline Director of Technology Quest Software.
Copyright © 2006 Quest Software Best Practices for Stored Procedures By Kevin Kline SQL Server MVP.
Module 9 Designing and Implementing Stored Procedures.
Top Free Tools for Tuning SQL Statements Kevin Kline & Aaron Bertrand SQL Sentry, Inc.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Database Programming Sections 11 & 12 –Sequences, Indexes, and Synonymns.
Module 11 Authorizing Users to Access Resources. Module Overview Authorizing User Access to Objects Authorizing Users to Execute Code Configuring Permissions.
Chapter 4 An Introduction to SQL. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.4-2 Topics in this Chapter SQL: History and Overview The.
Different Constraint Types Type Where Declared When activated Guaranteed to hold? Attribute with attribute on insertion not if CHECK or update subquery.
Session 1 Module 1: Introduction to Data Integrity
DML Statements contd.. SQL Server CURSORS Cursor is used in handling results of select query for data calculations Cursors are used as buffered.
Retele de senzori Curs 2 - 1st edition UNIVERSITATEA „ TRANSILVANIA ” DIN BRAŞOV FACULTATEA DE INGINERIE ELECTRICĂ ŞI ŞTIINŢA CALCULATOARELOR.
SQL Triggers, Functions & Stored Procedures Programming Operations.
 CONACT UC:  Magnific training   
Dave LinkedIn
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:
SQL Basics Review Reviewing what we’ve learned so far…….
Diving into Query Execution Plans ED POLLACK AUTOTASK CORPORATION DATABASE OPTIMIZATION ENGINEER.
Session Name Pelin ATICI SQL Premier Field Engineer.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
Stored Procedures – Facts and Myths
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
UFC #1433 In-Memory tables 2014 vs 2016
Oracle Certified 1z0-047 Exam Questions
Introduction What is a Database?.
The Killing Cursors Cyndi Johnson
Cyndi Johnson Senior Software Engineer at AdvancedMD Killing Cursors.
Introduction To Structured Query Language (SQL)
Contents Preface I Introduction Lesson Objectives I-2
Cyndi Johnson Senior Software Engineer at AdvancedMD Killing Cursors.
SQL Server Query Design and Optimization Recommendations
Responding to Data Manipulation Via Triggers
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.

Your 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 Specifying the schema o SP_xyz Prefix o Queries with IN (…) / OR o Unwanted recompiles o Transitive property of indexes Prizes! Follow Up

13.Specifying the schema 14.SP_xyz Prefix 15.Unwanted recompiles 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

Always - when creating, altering, referencing objects Even if today everything is dbo o Object resolution works harder o Can yield multiple cached plans for the same query o DEMO

dbo stuff dbo.test Aaron stuff Aaron.test select * from test dbo.sptest (Aaron) Exec sptest

Stored procedures with the SP_ prefix can: o Cause metadata overhead o Induce needless SP:CacheMiss events About 10% performance hit (duration) in my tests Blog post:

Meaning: o column IN (a,b,c) o column = a OR column = b OR column = c These optimize to the exact same plan IN is my personal preference (brevity) Do *not* replace with UNION or UNION ALL Can use TVPs to replace CSV/XML or dynamic SQL DEMO

Execution Read from system table NO In Memory? compile optimize Execute YES ReComp Execute

Expected: Because we request it: oCREATE PROC … WITH RECOMPILE or EXEC myproc … WITH RECOMPILE oSP_RECOMPILE foo Expected: Plan was aged out of memory Unexpected: Interleaved DDL and DML Unexpected: Big changes since last execution: o Schema changes to objects in underlying code o New/updated index statistics o Sp_configure

CREATE PROC testddldml AS … ; CREATE TABLE #testdml;-- (DDL) INSERT INTO #testdml;-- (DML + RECOMPILE) ALTER TABLE #testdml;-- (DDL) INSERT INTO #testdml;-- (DML + RECOMPILE) DROP TABLE #testdml;-- (DDL)

Schema changes: o Column additions, deletions o Data type changes o Constraint additions, deletions o Rule/Default bindings Index used by query is dropped

SQL Server recompiles to code to take advantage of new statistics for both manually and automatically created statistics: o Auto_update statistics o Auto_create statistics o Update statistics

In algebra: o when A = B and B = C, then … o A = C ! Some older versions of SQL Server do not know this. Incorporate the transitive property into JOIN and WHERE subclauses when appropriate: oSELECT … FROM table1 AS t1 oJOIN table2 AS t2 ON t2.my_id = t1.my_id oJOIN table3 AS t3 ON t3.my_id = t1.my_id AND t3.my_id = t2.my_id

Specify the schema, even if you only have dbo. Don’t use the SP_xyz Prefix. Understand queries with IN (…) / OR clauses. Remember unwanted recompiles. Don’t expect SQL Server to know the transitive property of indexes.

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: