INTELLIGENT DATA SOLUTIONS WWW.PRAGMATICWORKS.COM SQL Server 2016 The Query Store Author: Sean Werick Company: Pragmatic Works.

Slides:



Advertisements
Similar presentations
Module 13: Performance Tuning. Overview Performance tuning methodologies Instance level Database level Application level Overview of tools and techniques.
Advertisements

Which server is right for you? Get in Contact with us
Power BI Sites and Mobile BI. What You Will Learn Sharing and Collaboration Introducing Power BI Exploring Power BI Features and Services Partner Opportunities.
Technical BI Project Lifecycle
A Fast Growing Market. Interesting New Players Lyzasoft.
Microsoft Ignite /16/2017 3:29 PM
Meanwhile RAM cost continues to drop Moore’s Law on total CPU processing power holds but in parallel processing… CPU clock rate stalled… Because.
Microsoft SQL Server x 46% 900+ For Hosting Service Providers
MCITP Guide to Microsoft Windows Server 2008 Server Administration (Exam #70-646) Chapter 14 Server and Network Monitoring.
SQL Server 2014 Enterprise Edition Brad Jarocki Adam Bogobowicz Matt Haynes.
MICROSOFT CONFIDENTIAL Sept 2009 | Page 1 | BDM Presentation.
Time SQL Server 2012 Highlights and ColumnStore Index09:00 – 10:15 AlwaysOn and Contained Databases10:45 – 12:15 PowerPivot and PowerView (BI)13:00 –
SharePoint 2010 Business Intelligence Module 2: Business Intelligence.
SQL Server 2014: The Data Platform for the Cloud.
Virtual techdays INDIA │ November 2010 PowerPivot for Excel 2010 and SharePoint 2010 Joy Rathnayake │ MVP.
Module 7: Fundamentals of Administering Windows Server 2008.
SQL Server 2012 Session: 1 Session: 3 Introduction to SQL Server 2012 Data Management Using Microsoft SQL Server.
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment, Enhanced Chapter 11: Monitoring Server Performance.
SQL Server 2016 : New Features
Microsoft Ignite /24/2017 9:51 PM
Securely Synchronize and Share Enterprise Files across Desktops, Web, and Mobile with EasiShare on the Powerful Microsoft Azure Cloud Platform MICROSOFT.
Mission critical features in SQL 2016 David Lyth Pat Martin Premier Field Engineers, Microsoft New Zealand.
Text Microsoft to Or Tweet #uktechdays Questions?
+ Logentries Is a Real-Time Log Analytics Service for Aggregating, Analyzing, and Alerting on Log Data from Microsoft Azure Apps and Systems MICROSOFT.
Matt Lavery & Joanna Podgoetsky Being a DBA is cool again with SQL 2016 DAT335 A.
Microsoft Azure and DataStax: Start Anywhere and Scale to Any Size in the Cloud, On- Premises, or Both with a Leading Distributed Database MICROSOFT AZURE.
Warwick Rudd – Henry Rooney – How Available is SQL Server 2016? DAT33 6.
Data-Centric Security and User Access Controls for Hadoop on Microsoft Azure MICROSOFT AZURE APP BUILDER PROFILE: BLUETALON BlueTalon provides data-centric.
Please note that the session topic has changed
Gain High Availability Performance and Scale of Applications Running on Windows Azure with KEMP Technologies’ Virtual LoadMaster COMPANY PROFILE: KEMP.
Technology Drill Down: Windows Azure Platform Eric Nelson | ISV Application Architect | Microsoft UK |
SQL Server 2012 Session: 1 Session: 4 SQL Azure Data Management Using Microsoft SQL Server.
Business Intelligence for everyone 2 For BI to deliver maximum value, all Information Workers must participate: Broad access to uncover and share insights.
SQL Server 2016 New Innovations. Microsoft Data Platform Relational Beyond Relational On-premises Cloud Comprehensiv e Connected Choice SQL Server Azure.
Consistent experience is everything End-to-end mobile BI Advanced Analytics Enterprise-grade DW Mission critical OLTP Speed Agility Proven Feedback.
Excel Services Displays all or parts of interactive Excel worksheets in the browser –Excel “publish” feature with optional parameters defined in worksheet.
SQL Server Evolution New innovations Jen Underwood Sr. Program Manager of Business Intelligence & Analytics Microsoft George Walters Sr. Technical Solutions.
Warwick Rudd | Principal Consultant – consulting.com.au #456 | Auckland 2015 Mission Critical SQL Server.
SQL Server 2016 Mohit K. Gupta | Microsoft SQL Server PFE.
Configuring SQL Server for a successful SharePoint Server Deployment Haaron Gonzalez Solution Architect & Consultant Microsoft MVP SharePoint Server
MICROSOFT AZURE APP BUILDER PROFILE: RAVERUS LTD. Raverus is a customer-driven company engaged in providing software applications designed to improve and.
SQL 2016 – WHAT’S NEW? David Cobb Daveslog.com.
Microsoft Power BI Stack
Improve query performance with the new SQL Server 2016 query store!! Michelle Gutzait Principal Consultant at
SQL Server 2016 editions – what’s new Express Mission critical performance SecurityData warehousing Business intelligence Advanced Analytics Hybrid cloud.
DreamFactory for Microsoft Azure Is an Open Source REST API Platform That Enables Mobilization of Data in Minutes across Frameworks and Storage Methods.
Session Name Pelin ATICI SQL Premier Field Engineer.
Microsoft Dynamics NAV Dynamics NAV 2016 one Azure SQL Dmitry Chadayev Microsoft.
Microsoft Dynamics NAV Microsoft Dynamics NAV managed service for partners, under the hood Dmitry Chadayev Corporate Vice President, Microsoft.
Sean Werick Principal Consultant
HDC: SQL Server 2016 New Features & Demos. Phil Brammer
Managing a database environment in the cloud
Use relational database as a service
4/18/2018 6:56 AM © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN.
Self-service BI per user
Data Platform and Analytics Foundational Training
System Center Marketing
System Center Marketing
Business Critical Application Platform
SQL 2016 new Hosting Offers Secure Database Hybrid HyperScale
Introduction Module 16 9/5/2018 9:26 PM
Database Testing in Azure Cloud
Business Critical Application Platform
Microsoft Build /20/2018 5:17 AM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY,
Welcome! Power BI User Group (PUG)
Welcome! Power BI User Group (PUG)
SQL Server 2016 Query Data Store
DAT381 Team Development with SQL Server 2005
Welcome to SQLSaturday #767! Hosted by Lincoln SQL Server User Group
SQL Server 2016 High Performance Database Offer.
Presentation transcript:

INTELLIGENT DATA SOLUTIONS SQL Server 2016 The Query Store Author: Sean Werick Company: Pragmatic Works

INTELLIGENT DATA SOLUTIONS Who is Pragmatic Works? o 100% Microsoft SQL Server Focused o Team of Microsoft MVPs, Authors, Presenters o Concentrated on Optimizing your Data Lifecycle What is Pragmatic Works? o Software Solutions o Training Offerings o Professional Services Why Pragmatic Works? o Microsoft Gold Partner – Data Platform & Business Intelligence o Microsoft’s only “National Solution Provider” for Business Intelligence o Microsoft Analytics Platform System Implementation Partner of the Year o INC Magazine’s Fastest 5000 Growing Companies o Leader in offerings centered around Microsoft’s emerging technologies About Pragmatic Works

INTELLIGENT DATA SOLUTIONS Principal Consultant Community Speaker Blogs: About Sean

SQL Server 2016 New Innovations

Cloud first Speed Agility Proven Feedback

All of this results in a better on-premises SQL Server Announcing SQL Server 2016

SQL Server OLTP SQL Server data warehouse ETL In-memory ColumnStore In-memory OLTP Real-time fraud detection In-memory enhancements Operational analytics & enhanced performance Fraud detected 2-24 hrs

dbo.Patients Jane Doe Name SSN USA Country Jim Gray USA John Smith USA dbo.Patients Jane Doe Name 1x7fg655se2e SSN USA Jim Gray0x7ff654ae6dUSA John Smith0y8fj754ea2cUSA Country Result Set Jim Gray Name Jane Doe Name 1x7fg655se2e SSN USA Country Jim Gray0x7ff654ae6dUSA John Smith0y8fj754ea2cUSA dbo.Patients SQL Server ciphertext Query Always Encrypted Help protect data at rest and in motion, on-premises & cloud Trusted Apps SELECT Name FROM Patients Result Set Jim Gray Name SELECT Name FROM Patients Column Encryption Key Enhanced ADO.NET Library Column Master Key Client side

Mission critical performance Performance Operational analytics In-memory OLTP for more applications Query data store Native JSON Temporal database support Security Always Encrypted Row Level Security Dynamic Data Masking Availability Enhanced AlwaysOn 3 synchronous replicas for auto failover across domains Round robin load balancing of replicas DTC for transactional integrity across database instances with AlwaysOn Enhanced online operations Scalability Enhanced database caching Support for Windows Server TB memory support

PolyBase Query relational and non-relational data with T-SQL T-SQL query SQL Server Hadoop Quote: ************************ ********************** ********************* ********************** *********************** $ Jim Gray Name 11/13/58 DOB WA State Ann Smith04/29/76ME

Data Scientist Interact directly with data Built-in to SQL Server Data Developer/DBA Manage data and analytics together Built-in advanced analytics In-database analytics at massive scale Example Solutions Sales forecasting Warehouse efficiency Predictive maintenance Relational Data Analytic Library T-SQL Interface Extensibility ? R R Integration Microsoft Azure Marketplace New R scripts Credit risk protection

SQL Server Report Builder SQL Server Report Builder SQL Server BI “Reporting Services” Power BI Desktop Mobile reports Paginated reports SQL Server BI “Reporting Services” Power BI Desktop Mobile reports Paginated reports Power BI Power BI Desktop Microsoft Excel Mobile reports Paginated reports Power BI Power BI Desktop Microsoft Excel Mobile reports Paginated reports Power BI Web Portal Power BI Desktop CONSUME MANAGE CREATE Microsoft Excel “Datazen” Publisher** Report Designer in SQL Server Data Tools Windows App Android App iOS App Report Server Web portal (all BI report types) SharePoint Web

Rich visualizations on mobile devices

Deeper insights across data Access any data PolyBase Power Query for analytics and reporting Enhanced SSIS Designer support for previous SSIS versions Support for Power Query Scale and manage Enterprise-grade Analysis Services New single SSDT in Visual Studio 2015 Enhanced MDS Excel add-in 15x faster More granular security roles Archival options for transaction logs Reuse entities across models Powerful insights Built-in advanced analytics Business insights through rich visualizations on mobile devices Enhanced Reporting Services

Introducing Azure SQL Data Warehouse Integration with Power BI, ADF, and Machine Learning services Separate storage & compute Elastic scale Scale-out relational data warehouse MPP massive scale-out

Order history Name SSN Date Jane Doecm61ba906fd 2/28/200 5 Jim Grayox7ff654ae6d 3/18/200 5 John Smithi2y36cg776rg 4/10/200 5 Bill Brownnx290pldo90l 4/27/200 5 Sue Danielsypo85ba616rj 5/12/200 5 Sarah Jonesbns51ra806fd 5/22/200 5 Jake Marksmci12hh906fj 6/07/200 5 Eric Mearsutb76b916gi 6/18/201 4 Rachel Hoganpx61hi9306fj7/1/2014 Sam Johnsonol43bi506gd 7/12/201 4 David Simontx83hal916fi 7/29/201 4 Michelle Burnsnb95re926gi 8/10/201 4 Reed Deanvc61ira536fe 8/23/201 4 Order history Name SSN Date Jane Doecm61ba906fd 2/28/200 5 Jim Grayox7ff654ae6d 3/18/200 5 John Smithi2y36cg776rg 4/10/200 5 Bill Brownnx290pldo90l 4/27/200 5 Customer data Product data Order History Stretch to cloud Stretch SQL Server into Azure Stretch warm and cold tables to Azure with remote query processing App Query Microsoft Azure Jim Grayox7ff654ae6d3/18/2005

Cortana Analytics Suite Transform data into intelligent action

INTELLIGENT DATA SOLUTIONS What is the Query Store? A SQL Server 2016 (and SQL DB) Feature that can be Enabled Provides insight on query plan choice and performance Simplifies performance troubleshooting by quickly finding performance differences caused by query plan changes Automatically captures a history of queries, plans, and runtime statistics, and retains these for review Separates data by time windows to better illustrate database usage patterns and understand when query plan changes happened on the server

INTELLIGENT DATA SOLUTIONS Why Use the Query Store? Query Performance Insight Helps Satisfy 2 Main Goals Performance Cost

INTELLIGENT DATA SOLUTIONS Why Use the Query Store? All about the DTUs (PaaS) A Database Transaction Unit (DTU) is a blended measure of the resources allocated at each performance level. Processor - % Processor Time Logical Disk - Disk Reads/sec Logical Disk - Disk Writes/sec Database - Log Bytes Flushed/sec Review the list of top resource-consuming queries Select an individual query to view its details Click Settings to customize how data is displayed or to show a different time period Open Index Advisor * (PaaS) and check if any recommendations are available Performance Cost * Index Advisor - WHAT IS THE REAL COST?

INTELLIGENT DATA SOLUTIONS How the Query Store “Works”

INTELLIGENT DATA SOLUTIONS Does It Work with In-Memory OLTP? SQL Server Query Store allows you to monitor the performance of natively compiled code for workloads running in-memory OLTP Compile and runtime statistics are collected and exposed the same way as for disk-based workloads When you migrate to in-memory OLTP you can continue using Query Store views in SQL Server Management Studio as well as custom scripts you have developed for disk-based workloads before migration This saves your investment in learning Query Store technology and makes it generally usable for troubleshooting all type of workloads

INTELLIGENT DATA SOLUTIONS How to Use the Query Store In Just 3 Easy Steps, You TOO can be a DBA!! Okay, okay. This may take a bit more effort and knowledge.

INTELLIGENT DATA SOLUTIONS There are 2 Ways to Enable Query Store By Using the Query Store Page in SSMS Setting up the Query Store In Object Explorer, right-click a database, and then click Properties

INTELLIGENT DATA SOLUTIONS By Using the Query Store Page in SSMS Setting up the Query Store In the Database Properties dialog box, select the Query Store page Select related attributes General o Operation Mode (Read or Read/Write) Monitoring o Data Flush Interval (Manual Entry in Minutes) o Statistics Collection (5 mins, 10 mins, 15 mins, 30 mins, 1 hr, 1 day) Max Size o Query Store Capture Mode (All or Auto) o Size Based Cleanup Mode (Off or Auto) o Stale Query Threshold (Manual Entry in Days)

INTELLIGENT DATA SOLUTIONS By Using T-SQL Statements Use the ALTER DATABASE statement ALTER DATABASE AdventureWorks2012 SET QUERY_STORE = ON; Ability to Setting up the Query Store

INTELLIGENT DATA SOLUTIONS GUI OptionT-SQL Option Operation Mode (Requested)OPERATION_MODE Data Flush Interval (Minutes)DATA_FLUSH_INTERVAL_SECONDS Statistics Collection IntervalINTERVAL_LENGTH_MINUTES Max Size (MB)MAX_STORAGE_SIZE_MB Query Store Capture ModeQUERY_CAPTURE_MODE Size Based Cleanup ModeSIZE_BASED_CLEANUP_MODE Stale Query Threshold (Days)CLEANUP_POLICY (STALE_QUERY_THRESHOLD_DAYS) MAX_PLANS_PER_QUERY Query Store Options with T-SQL ALTER DATABASE [db_name] SET QUERY_STORE ( [Query Store options] ); -- Example ALTER DATABASE AdventureWorks SET QUERY_STORE ( MAX_STORAGE_SIZE_MB = 250 );

INTELLIGENT DATA SOLUTIONS sys.query_store_plansys.query_store_runtime_stats sys.query_context_settings sys.query_store_runtime_stats_interval sys.query_store_query sys.query_store_query_text plan_id runtime_stats_interval_id query_id context_settings_id query_text_id DATA MODEL sys.database_query_store_options What Information Does It Provide?

INTELLIGENT DATA SOLUTIONS What Information Does It Provide? *Additional Detail - Query Store ViewDescription sys.database_query_store_optionsQuery Store options for this database sys.query_context_settingsSemantics affecting context settings associated with a query (The same query text compiled under different settings may produce different results [depending on the underlying data]) sys.query_store_planEach execution plan associated with a query sys.query_store_queryInformation about the query and its associated overall aggregated runtime execution statistics sys.query_store_query_textTransact-SQL text and the SQL handle of the query sys.query_store_runtime_statsInformation about runtime execution statistics information for the query sys.query_store_runtime_stats_intervalInformation about the start and end time of each interval over which runtime execution statistics information for a query has been collected

INTELLIGENT DATA SOLUTIONS Query Store Best Practices  Information and performance are generally a give and take, but there ARE some best practices  Every single setting in the Query Store has associated costs and benefits Treat Query Store performance tuning like an agile project with Sprints o Sprint 1 – Keep Operation Mode in READ/WRITE mode for information collection This reduces write time, and subsequent overall database performance, for data collection as no reporting is occurring o Sprint 2 – Change Operation Mode to READ mode for analysis and actual performance tuning This it increases report performance because no writes are occurring. This also results in no “dirty reads” because of the asynchronous writes

INTELLIGENT DATA SOLUTIONS Query Store Best Practices Flush the data at specific business case intervals. For example, if performance of the DB seems to be poor around end of the month due financial reporting, consider using the Agile methodology to complete one iteration, then flush the data before the next iteration. Keep the Max Size small enough to keep the reporting relatively snappy, however, keep enough data to capture all of the business needs Keep an accurate Cleanup Policy as the business and reporting solution evolves Collect statistics as frequently as possible to see exactly which execution plans are being executed. If the statistics are not updated for some time, you may be looking at an old execution plan because the statistics have changed  Information and performance are generally a give and take, and it ultimately relies on each and every business and its processes

INTELLIGENT DATA SOLUTIONS Query Store Reporting Azure SQL DB Cloud offering (PaaS) Learn and adapt dynamically with your app Scale performance on the fly, without app downtime Build multitenant apps with customer isolation and efficiency Work within your preferred development environments Help protect and secure your app data

INTELLIGENT DATA SOLUTIONS Query Store Reporting The top queries view opens and the top CPU consuming queries are listed The top line shows overall DTU% for the database, while the bars show CPU% consumed by the selected queries during the selected interval The bottom grid represents aggregated information for the visible queries o Average CPU per query during observable interval o Total duration per query o Total number of executions for a particular query

INTELLIGENT DATA SOLUTIONS Query Store Reporting Viewing Individual Query Details Click any query in the list of top queries. The details view opens and the queries CPU consumption is broken down over time. Click around the chart for details. The top line is overall DTU%, and the bars are CPU% consumed by the selected query. Review the data to see detailed metrics including duration, number of executions, and resource utilization percentage for each interval the query was running.

INTELLIGENT DATA SOLUTIONS Query Store On Premise Reporting On Premise Solution?

INTELLIGENT DATA SOLUTIONS Query Store Dashboards SSMS

INTELLIGENT DATA SOLUTIONS Custom Views and SQL HOW? sys.query_store_plansys.query_store_runtime_stats sys.query_context_settings sys.query_store_runtime_stats_interval sys.query_store_query sys.query_store_query_text plan_id runtime_stats_interval_id query_id context_settings_id query_text_id sys.database_query_store_options

INTELLIGENT DATA SOLUTIONS Query Store Admin with T-SQL Stored ProcedureDescription sp_query_store_flush_dbFlushes the in-memory portion of the Query Store data to disk sp_query_store_reset_exec_statsClears the runtime stats for a specific query plan from the query store sp_query_store_force_planEnables forcing a particular plan for a particular query. When a plan is forced for a particular query, every time SQL Server encounters the query, it tries to force the plan in the optimizer. If plan forcing fails, a XEvent is fired and the optimizer is instructed to optimize in the normal way. sp_query_store_unforce_planEnables unforcing a particular plan for a particular query sp_query_store_remove_planRemoves a single plan from the query store sp_query_store_remove_queryRemoves the query, as well as all associated plans and runtime stats from the query store

INTELLIGENT DATA SOLUTIONS Forcing Execution Plans OLD WAY 1.Run SET SHOWPLAN_XML ON to return the XML Execution Plan, or alternatively, grab the XML Plan from the sys.dm_exec_text_query_plan DMF) 2.Create the Plan Guide using the sp_create_plan_guide Stored Procedure

INTELLIGENT DATA SOLUTIONS Forcing Execution Plans NEW WAY 1.Click the “Force Plan” button inside one of the Query Store reports 2.Use the sp_query_store_force_plan SP. EXEC sp_query_store_force_plan 136, 146;

INTELLIGENT DATA SOLUTIONS Error State Remember to verify intermittently that the Query Store is still collecting data SELECT actual_state_desc, desired_state_desc, current_storage_size_mb, max_storage_size_mb, readonly_reason, interval_length_minutes, stale_query_threshold_days, size_based_cleanup_mode_desc, query_capture_mode_desc FROM sys.database_query_store_options; If there is a difference between the actual_state_desc and desired_state_desc, this indicates that a change of operations mode occurred automatically. The most common change is for the Query Store to silently switch to read-only mode. In extremely rarely circumstances, Query Store can end up in the ERROR state because of internal errors. When the actual state is read-only, use the readonly_reason column to determine the root cause. Typically, the Query Store transitioned to read-only mode because the size quota was exceeded. In that case the readonly_reason is set to

INTELLIGENT DATA SOLUTIONS Error State How to Fix Reactive Increase the maximum storage size by using the MAX_STORAGE_SIZE_MB option of ALTER DATABASE Clean up Query Store data ALTER DATABASE [QueryStoreDB] SET QUERY_STORE CLEAR; Change Operation Mode back to READ/WRITE ALTER DATABASE [QueryStoreDB] SET QUERY_STORE (OPERATION_MODE = READ_WRITE); Proactive Apply best practices, specifically related to Query Store size Make sure that most recent data is retained, configure time-based policy to remove stale information regularly Consider setting Query Capture Mode to Auto as it filters out queries that are usually less relevant for your workload

INTELLIGENT DATA SOLUTIONS Questions and Answers