Parameter Sniffing, Sp_Recompile

Slides:



Advertisements
Similar presentations
Advanced Oracle DB tuning Performance can be defined in very different ways (OLTP versus DSS) Specific goals and targets must be set => clear recognition.
Advertisements

Copyright © SoftTree Technologies, Inc. DB Tuning Expert.
Presenter: Red Devilic Sponsored by SQLViet.com 22/12/2013 SQL SERVER CONFERENCE HCMC 2013 DATABASE TUNING PERFORMANCE OVERVIEW.
SQL Server performance tuning basics
Copyright © 2011 by the Commonwealth of Pennsylvania. All Rights Reserved. Load Test Report.
Help! My table is getting too big! How to divide and conquer SQL Relay 2014.
SQL Server 2005 Implementation and Maintenance Chapter 10: Maintaining and Automating SQL Server.
Database Software File Management Systems Database Management Systems.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
SQL Server Integration Services 2008 &2012
Convergence /20/2017 © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
March 19981© Dennis Adams Associates Tuning Oracle: Key Considerations Dennis Adams 25 March 1998.
Module 7 Reading SQL Server® 2008 R2 Execution Plans.
Danette Dineen Riviello Magellan Health March 17,
How to solve a SQL performance problem Paul Zgondea.
Ashwani Roy Understanding Graphical Execution Plans Level 200.
Chapter 2: SQL – The Basics Objectives: 1.The SQL execution environment 2.SELECT statement 3.SQL Developer & SQL*Plus.
Copyright © Curt Hill Stored Procedures In Transact-SQL.
Introduction to CS520/CS596_026 Lecture Two Gordon Tian Fall 2015.
Module 8: Implementing Stored Procedures. Overview Implementing Stored Procedures Creating Parameterized Stored Procedures Working With Execution Plans.
Programming in R SQL in R. Running SQL in R In this session I will show you how to: Run basic SQL commands within R.
PowerBuilder Online Courses - by Prasad Bodepudi Database Painter Primary & Foreign Keys Extended Attributes PowerBuilder System Tables Database Profiles.
CHANGE DATA CAPTURE: A BRIEF OVERVIEW PRESENTED BY TIM WEIGEL
DAT410 SQL Server 2005 Optimizing Procedural Code Kimberly L. Tripp President/Founder, SQLskills.com.
Maintenance Practices. Goal  Automate the necessary DBA chores to put organizations on the path of having healthier, consistent and more trustworthy.
Indexing Fundamentals Steve Hood SimpleSQLServer.com.
Execution Plans Detail From Zero to Hero İsmail Adar.
Why Should I Care About … The Plan Cache? Tuning When Stakeholders Won’t Say Where It Hurts.
You Inherited a Database Now What? What you should immediately check and start monitoring for. Tim Radney, Senior DBA for a top 40 US Bank President of.
Best 20 jobs jobs sites.
Oracle Standby Implementation Tantra Invedy. Standby Database Introduction Fail over Solution Disaster Recovery Solution if remote Ease of implementation.
Web Systems & Technologies
You Inherited a Database Now What?
Cleveland SQL Saturday Catch-All or Sometimes Queries
Are You There, DBA? It’s Me, The App Developer.
Things You Can Find in the Plan Cache.
Become a SQL Server Performance Detective
LHCb Conditions Database TEG Workshop 7 November 2011 Marco Clemencic
Purpose, Pitfalls and Performance Implications
Introduction to Execution Plans
Performance Monitoring Using Extended Events, DMVs & Query Store
The Key to the Database Engine
Let’s Get Started! Rick Lowe Why Should I Care About … The Plan Cache
Why Should I Care About … The Plan Cache?
Query Optimization Techniques
Purpose, Pitfalls and Performance Implications
Why Should I Care About … The Plan Cache?
JULIE McLAIN-HARPER LINKEDIN: JM HARPER
Plan cache performance tuning
Statistics: What are they and How do I use them
Steve Hood SimpleSQLServer.com
Let’s Get Started! Rick Lowe Why Should I Care About … The Plan Cache
Why Should I Care About … The Plan Cache?
Why Should I Care About … The Plan Cache?
Parameter Sniffing: the Good, the Bad, and the Ugly
You Inherited a Database Now What?
Introduction to Execution Plans
Parameter Sniffing: the Good,the Bad, and the Ugly
Parameter Sniffing on SQL Server
Parameter Sniffing: the Good, the Bad, and the Ugly
Why Should I Care About … The Plan Cache?
Analyzing Performance Problems Using XEvents, DMVs & Query Store
Jean Joseph DBA/Developer
Jean Joseph DBA\DEVELOPER
Introduction to Execution Plans
Query Optimization Techniques
Introduction to Execution Plans
Advanced Database Topics
Analyzing Performance Problems Using XEvents, DMVs & Query Store
Presentation transcript:

Parameter Sniffing, Sp_Recompile Teshale Misganaw And Tim Weigel

Teshale Misganaw One of the DBA at PGI SQL Server = few years A limited experience on DB2 and Oracle tmisganaw@gmail.com 719-896-9423

The Problem Production Sites 27 servers Customers make calls to Connect Summo Logioc alert (One Server) Proc is timing out Proc is taking longer than 800000 millisecond

The Research Start looking for Expensive Procs (CPU Intensive) sys.dm_exec_procedure_stats Outer apply with sys.dm_exec_query_plan sys.dm_exec_sql_text Found one PROC which was executed so many times Major KeyLookup (execution plan) Index Seek but query needs additional columns Add cover index to satisfy the lookup 35 columns (not practical)

The Research The BAD PLAN usually comes right after Index Maintenance We dropped the whole index maintenance job and recreated Not working Tim went further and studied the data distribution Found two combination of data that triggers the BAD PLAN Column1 = 123… Coulmn2 = 567…. HAAAA

The Research We suspect Parameter Sniffing Flush the Cache for a single PROC DBCC FREEPROCCACHE(planhandle) The next time the PROC runs it picks up good plan Good Sign After the next day maintenance plan, BAD PLAN At least we are getting somewhere

The Solution Problem Starts right after maintenance plan We want to make sure it is covered all the time Create a job that runs every 5 minuets that reads sys.dm_exec_procedure_stats max_elapsed_time If max_elapsed_time > 800000 , start the job

The JOB declare @flush_bad_plan_out varchar(100) if (select MAX(max_elapsed_time) from sys.dm_exec_procedure_stats where object_id = object_id('PROC_NAME')) > 800000 set @flush_bad_plan_out = 'sp_recompile ''PROC_NAME''' exec(@flush_bad_plan_out)