Sofia, Bulgaria | 9-10 October The Query Governor Richard Campbell Stephen Forte Richard Campbell Stephen Forte.

Slides:



Advertisements
Similar presentations
Performance Tuning Compiled from: Oracle Database Administration, Session 13, Performance, Harvard U Oracle Server Tuning Accelerator, David Scott, Intec.
Advertisements

Adam Jorgensen Pragmatic Works Performance Optimization in SQL Server Analysis Services 2008.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Memory Management and Protection Part 3:Virtual memory, mode switching,
By Snigdha Rao Parvatneni
RAPTOR Syntax and Semantics By Lt Col Schorsch
CSI 3120, Implementing subprograms, page 1 Implementing subprograms The environment in block-structured languages The structure of the activation stack.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Computer Organization and Architecture
MCITP Guide to Microsoft Windows Server 2008 Server Administration (Exam #70-646) Chapter 14 Server and Network Monitoring.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Operating Systems (CSCI2413) Lecture 3 Processes phones off (please)
CIS607, Fall 2005 Semantic Information Integration Article Name: Clio Grows Up: From Research Prototype to Industrial Tool Name: DH(Dong Hwi) kwak Date:
Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server.
Service Broker Lesson 11. Skills Matrix Service Broker Service Broker, provides a solution to common problems with message delivery and consistency that.
Layers and Views of a Computer System Operating System Services Program creation Program execution Access to I/O devices Controlled access to files System.
Today’s Agenda Chapter 12 Admin Tasks Chapter 13 Automating Admin Tasks.
Selecting and Implementing An Embedded Database System Presented by Jeff Webb March 2005 Article written by Michael Olson IEEE Software, 2000.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
System Calls 1.
1 HEAPS & PRIORITY QUEUES Array and Tree implementations.
Introduction to Python
COMP 410 & Sky.NET May 2 nd, What is COMP 410? Forming an independent company The customer The planning Learning teamwork.
Sofia, Bulgaria | 9-10 October Using XQuery to Query and Manipulate XML Data Stephen Forte CTO, Corzen Inc Microsoft Regional Director NY/NJ (USA) Stephen.
PHP meets MySQL.
CS 114 – Class 02 Topics  Computer programs  Using the compiler Assignments  Read pages for Thursday.  We will go to the lab on Thursday.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Triggers A Quick Reference and Summary BIT 275. Triggers SQL code permits you to access only one table for an INSERT, UPDATE, or DELETE statement. The.
April 26, CSE8380 Parallel and Distributed Processing Presentation Hong Yue Department of Computer Science & Engineering Southern Methodist University.
Chapter 25: Code-Tuning Strategies. Chapter 25  Code tuning is one way of improving a program’s performance, You can often find other ways to improve.
SQLRX – SQL Server Administration – Tips From the Trenches SQL Server Administration – Tips From the Trenches Troubleshooting Reports of Sudden Slowdowns.
Stored Procedure. Objective At the end of the session you will be able to know :  What are Stored Procedures?  Create a Stored Procedure  Execute a.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 9: Virtual Memory.
1 Memory Management Chapter 7. 2 Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated to ensure a reasonable.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
1 CSCD 326 Data Structures I Hashing. 2 Hashing Background Goal: provide a constant time complexity method of searching for stored data The best traditional.
SQL Server 2005 XML Datatype David Wilson Ohio North SQL Server Special Interest Group July 12, 2007.
Informationsteknologi Wednesday, October 3, 2007Computer Systems/Operating Systems - Class 121 Today’s class Memory management Virtual memory.
CHP-3 STACKS.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Presented by Vishy Grandhi.  Lesson 1: AX Overview  Lesson 2: Role based security  Lesson 3: Monitoring  Troubleshooting.
1 Process Description and Control Chapter 3. 2 Process A program in execution An instance of a program running on a computer The entity that can be assigned.
CS 153: Concepts of Compiler Design October 12 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
INTRODUCTION TO COMPUTER PROGRAMMING(IT-303) Basics.
1 Contents Memory types & memory hierarchy Virtual memory (VM) Page replacement algorithms in case of VM.
Chapter 2 Memory and process management
Cleveland SQL Saturday Catch-All or Sometimes Queries
JSP (Java Server Page) JSP is server side technology which is used to create dynamic web pages just like Servlet technology. This is mainly used for implementing.
Query Performance Tuning: Start to Finish
Mechanism: Address Translation
Day 23 Virtual Memory.
Day 24 Virtual Memory.
C++ Programming: From Problem Analysis to Program Design
Arrays, For loop While loop Do while loop
Dynamic Programming.
Fundamentals of Programming
CMPE 152: Compiler Design October 4 Class Meeting
Operating Systems.
Chapter 2: Operating-System Structures
Memory management Explain how memory is managed in a typical modern computer system (virtual memory, paging and segmentation should be described.
Contents Memory types & memory hierarchy Virtual memory (VM)
Data Structures & Algorithms
Course Overview PART I: overview material PART II: inside a compiler
Little Man Computer There’s a little man in the mailroom that follows each instruction to the letter but he can only follow one instruction at a time.
Process.
Chapter 2: Operating-System Structures
Dynamic SQL Konstantin Osipov, MySQL AB.
Mechanism: Address Translation
CSE 542: Operating Systems
Presentation transcript:

Sofia, Bulgaria | 9-10 October The Query Governor Richard Campbell Stephen Forte Richard Campbell Stephen Forte

Sofia, Bulgaria | 9-10 October Speakers.Bio.ToPhoto()

Sofia, Bulgaria | 9-10 October Agenda ●What is a Query Governor? ●Evaluating the Query ●Evaluating the State of the Server ●Putting it All Together ●Implementation and Enforcement ●What is a Query Governor? ●Evaluating the Query ●Evaluating the State of the Server ●Putting it All Together ●Implementation and Enforcement

Sofia, Bulgaria | 9-10 October What is a Query Governor? ●Controls what queries can be run ●Two standard techniques: ●By cost ●By time ●Controls what queries can be run ●Two standard techniques: ●By cost ●By time

Sofia, Bulgaria | 9-10 October What is a Query Governor? ●SET QUERY_GOVERNOR_COST_LIMIT ●No queries above this value will execute ●EVER! ●You have to modify queries to stay below the limit ●Add indexes, break down steps, etc. ●SET QUERY_GOVERNOR_COST_LIMIT ●No queries above this value will execute ●EVER! ●You have to modify queries to stay below the limit ●Add indexes, break down steps, etc.

Sofia, Bulgaria | 9-10 October What is a Query Governor? ●Enforced outside SQL Server ●Set a maximum amount of time to execute a query ●If the query exceeds that time, it fails ●You have to run the query to see if it takes too long ●Enforced outside SQL Server ●Set a maximum amount of time to execute a query ●If the query exceeds that time, it fails ●You have to run the query to see if it takes too long

Sofia, Bulgaria | 9-10 October What is a Query Governor? ●Assess the cost of the query ●Assess the state of the server ●Algorithmically decide whether or not to execute ●Under low load conditions, more queries can run ●Under high load, only high priority queries run ●Assess the cost of the query ●Assess the state of the server ●Algorithmically decide whether or not to execute ●Under low load conditions, more queries can run ●Under high load, only high priority queries run

Sofia, Bulgaria | 9-10 October Evaluating the Query ●SQL Server 2005 will return query plans in XML format ●Makes it easy to programmatically extract useful information from a query, such as cost ●But you can’t turn showplan_xml on and off easily ●And that’s where the CLR comes in ●SQL Server 2005 will return query plans in XML format ●Makes it easy to programmatically extract useful information from a query, such as cost ●But you can’t turn showplan_xml on and off easily ●And that’s where the CLR comes in

Sofia, Bulgaria | 9-10 October Evaluating the Query ●The code to fetch the query plan is written in C# ●It takes the SQL statement and runs showplan_xml on it ●Loads that xml into a variable and returns it as a string ●The code to fetch the query plan is written in C# ●It takes the SQL statement and runs showplan_xml on it ●Loads that xml into a variable and returns it as a string

Sofia, Bulgaria | 9-10 October Evaluating the Query ●Using the C# code in SQL Server ●Turn on CLR ●Create an assembly from the compiled DLL ●Create a stored procedure that uses the assembly ●Go Crazy! ●Using the C# code in SQL Server ●Turn on CLR ●Create an assembly from the compiled DLL ●Create a stored procedure that uses the assembly ●Go Crazy!

Sofia, Bulgaria | 9-10 October Evaluating the Query ●The evaluator code will check any query ●Actual SQL statements like SELECT ●Stored procedures ●Showplan knows what kind of query is about to be run ●Could be useful for SQL Injection defense ●The evaluator code will check any query ●Actual SQL statements like SELECT ●Stored procedures ●Showplan knows what kind of query is about to be run ●Could be useful for SQL Injection defense

Sofia, Bulgaria | 9-10 October Evaluating the Query ●Use XQuery to extract data from the XML Showplan ●An expression language for finding XML elements ●Handles typing, multiple elements, etc. ●Use XQuery to extract data from the XML Showplan ●An expression language for finding XML elements ●Handles typing, multiple elements, etc.

Sofia, Bulgaria | 9-10 October Evaluating Server Status ●Could have written more C# code to pull WMI data ●But why? ●PerfMon Counter Logs write to SQL Server ●Simple, easy, effective ●Could have written more C# code to pull WMI data ●But why? ●PerfMon Counter Logs write to SQL Server ●Simple, easy, effective

Sofia, Bulgaria | 9-10 October Evaluating Server Status ●Avg. Disk Queue Length ●If its growing, your disk is falling behind ●Page Faults/sec ●If this number is high, you’re probably swapping memory to disk ●Processor Queue Length ●Tasks waiting for processor type, could be an indicator of a lot of queries running ●Avg. Disk Queue Length ●If its growing, your disk is falling behind ●Page Faults/sec ●If this number is high, you’re probably swapping memory to disk ●Processor Queue Length ●Tasks waiting for processor type, could be an indicator of a lot of queries running

Sofia, Bulgaria | 9-10 October Evaluating Server Status ●There are thousands of counters ●Counters for system status ●Counters specific to SQL Server ●You can pick whatever you like! ●There are thousands of counters ●Counters for system status ●Counters specific to SQL Server ●You can pick whatever you like!

Sofia, Bulgaria | 9-10 October Evaluating Server Status ●Use queries to get an overall picture of the status of the server ●The correct numbers depend on the server! ●You have to account for other work your server might be doing ●Determine baseline numbers specific to the way your server is working ●Use queries to get an overall picture of the status of the server ●The correct numbers depend on the server! ●You have to account for other work your server might be doing ●Determine baseline numbers specific to the way your server is working

Sofia, Bulgaria | 9-10 October Evaluating Server State ●You want a single assessment: Low, Medium, High ●Use a stored procedure to check relevant counters ●Write the assessment as a log entry ●Use the Agent to run the stored procedure routinely ●You want a single assessment: Low, Medium, High ●Use a stored procedure to check relevant counters ●Write the assessment as a log entry ●Use the Agent to run the stored procedure routinely

Sofia, Bulgaria | 9-10 October Putting it All Together ●Develop a matrix of assessment ●Cost of the query ●State of the server ●Who is running this query? ●Write algorithms to make decisions ●Again, this depends on your situation, its very flexible ●Develop a matrix of assessment ●Cost of the query ●State of the server ●Who is running this query? ●Write algorithms to make decisions ●Again, this depends on your situation, its very flexible

Sofia, Bulgaria | 9-10 October Implementation ●Put the governor at the top of each stored procedure ●Requires following the rules ●Total cost inside a stored procedure gets challenging ●Put the governor at the top of each stored procedure ●Requires following the rules ●Total cost inside a stored procedure gets challenging

Sofia, Bulgaria | 9-10 October Implementation ●Call the governor before executing ●Simple to implement ●Again, relies on good behavior ●Call the governor before executing ●Simple to implement ●Again, relies on good behavior

Sofia, Bulgaria | 9-10 October Implementation ●All queries through the governor ●No rights to tables ●Governor executes query ●Works for dynamic SQL ●Not so good for stored procs ●All queries through the governor ●No rights to tables ●Governor executes query ●Works for dynamic SQL ●Not so good for stored procs

Sofia, Bulgaria | 9-10 October Questions?

Sofia, Bulgaria | 9-10 October Please fill out the survey forms! They are the key to amazing prizes that you can get at the end of each day Thank you!

Sofia, Bulgaria | 9-10 October