SQL Server 2017 has more cool features than just running on Linux

Slides:



Advertisements
Similar presentations
Chapter 9. Performance Management Enterprise wide endeavor Research and ascertain all performance problems – not just DBMS Five factors influence DB performance.
Advertisements

Meanwhile RAM cost continues to drop Moore’s Law on total CPU processing power holds but in parallel processing… CPU clock rate stalled… Because.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Database Performance Tuning and Query Optimization.
1 Robert Wijnbelt Health Check your Database A Performance Tuning Methodology.
Module 7 Reading SQL Server® 2008 R2 Execution Plans.
Informix IDS Administration with the New Server Studio 4.0 By Lester Knutsen My experience with the beta of Server Studio and the new Informix database.
MISSION CRITICAL COMPUTING Siebel Database Considerations.
Oracle9i Developer: PL/SQL Programming Chapter 11 Performance Tuning.
October 15-18, 2013 Charlotte, NC Accelerating Database Performance Using Compression Joseph D’Antoni, Solutions Architect Anexinet.
Dave LinkedIn
How to kill SQL Server Performance Håkan Winther.
SQL Server Statistics DEMO SQL Server Statistics SREENI JULAKANTI,MCTS.MCITP,MCP. SQL SERVER Database Administration.
Scott Fallen Sales Engineer, SQL Sentry Blog: scottfallen.blogspot.com.
SQL Server Statistics DEMO SQL Server Statistics SREENI JULAKANTI,MCTS.MCITP SQL SERVER Database Administration.
High Performance Functions SQLBits VI. Going backwards is faster than going forwards.
Improve query performance with the new SQL Server 2016 query store!! Michelle Gutzait Principal Consultant at
This document is provided for informational purposes only and Microsoft makes no warranties, either express or implied, in this document. Information.
Doing fast! Optimizing Query performance with ColumnStore Indexes in SQL Server 2012 Margarita Naumova | SQL Master Academy.
Session Name Pelin ATICI SQL Premier Field Engineer.
The PostgreSQL Query Planner Robert Haas PostgreSQL East 2010.
Deep dive on four SQL Server 2017 Features
SQL Server Statistics and its relationship with Query Optimizer
Joe Sack, Principal Program Manager, Microsoft
An introduction to Wait Statistics
Query Optimization Techniques
An Introduction to SQL Server 2017
Stored Procedures – Facts and Myths
Antonio Abalos Castillo
Query Tuning without Production Data
UFC #1433 In-Memory tables 2014 vs 2016
Parameter Sniffing in SQL Server Stored Procedures
Query Tuning without Production Data
Query Tuning without Production Data
Design Seamless Upgrades to SQL Server 2016 with Query Store
Database Performance Tuning and Query Optimization
Auditing in SQL Server 2008 DBA-364-M
Introduction to Execution Plans
Chapter 15 QUERY EXECUTION.
Working with Very Large Tables Like a Pro in SQL Server 2014
Decoding the Cardinality Estimator to Speed Up Queries
Please support our sponsors
Now where does THAT estimate come from?
Cardinality Estimator 2014/2016
SQL 2014 In-Memory OLTP What, Why, and How
Predictive Performance
The Road to Autonomous Databases
Deep Dive into Adaptive Query Processing
Statistics: What are they and How do I use them
Steve Hood SimpleSQLServer.com
Transactions, Locking and Query Optimisation
Hugo Kornelis Now where does THAT estimate come from? The nuts and bolts of cardinality estimation.
Transact SQL Performance Tips
Introduction to reading execution plans
Indexing For Optimal Performance
Dave Bland LinkedIn SQL Server Execution Plans: How to use them to find performance bottlenecks Dave Bland LinkedIn
Four Rules For Columnstore Query Performance
Recommending Materialized Views and Indexes with the IBM DB2 Design Advisor (Automating Physical Database Design) Jarek Gryz.
Hidden Gems of SQL Server 2014
Introduction to Execution Plans
When I Use NOLOCK AND OTHER HINTS
Chapter 11 Database Performance Tuning and Query Optimization
Diving into Query Execution Plans
Introduction to Execution Plans
From adaptive to intelligent: query processing in SQL Server 2019
T-SQL Basics: Coding for performance
Introduction to Execution Plans
Using wait stats to determine why my server is slow
Working with Very Large Tables Like a Pro in SQL Server 2017
Automagic Tuning - SQL Server 2019 and Beyond
From adaptive to intelligent:
Presentation transcript:

SQL Server 2017 has more cool features than just running on Linux Marcin Szeliga Damian Widera SQL Server 2017 has more cool features than just running on Linux

Sponsors

Session will begin very soon :) Please complete the evaluation form from your pocket after the session. Your feedback will help us to improve future conferences and speakers will appreciate your feedback! Enjoy the conference!

Marcin Szeliga Data philosopher 20 years of experience with SQL Server Data Platform MVP & MCT Microsoft Certified Solutions Expert Data Management and Analytics Cloud Platform and Infrastructure Business Intelligence Microsoft Certified Solutions Developer Azure Solution Architect

Damian Widera 15+ years of experience with SQL Server Data Platform MVP & MCT Microsoft Certified Solutions Expert Data Management and Analytics Business Intelligence http://sqlplayer.net/

Agenda Automated Tuning and wait statistics in Query Store Adaptive Query Processing Not only for developers… Credits to Joe Sack, Principal Program Manager, Microsoft

Automated Tuning and wait statistics in Query Store

Query execution and wait statistics Query Execution Started Query Execution WAIT: RESOURCE SEMAPHORE – MEMORY WAIT: PAGEIOLATCH_SH – Buffer IO Query Execution Finished

Why is my query slow? Locks Latches Buffer Latches Buffer IO Compilation Transaction Log IO Network IO Parallelism Memory User Waits Tracing Other Disk IO

Demo: Wait statistics in Query Store

Automatic tuning Server can now detect and correct these scenarios without manual intervention Recommended actions surfaced via sys.dm_db_tuning_recommendations We can now automatically switch to the last known good plan whenever the regression is detected

Demo: Automated Tuning

Adaptive Query Processing

Function Types Scalar Function Multi-statement table-valued function Series of T-SQL statements that evaluate to a scalar value Multi-statement table-valued function Series of T-SQL statements that populate a TABLE return variable Inline table-valued function TABLE return value is defined via a single SELECT statement

MSTVF execution plan example

Example “problem” query

MSTVF definition

Query Processing and Cardinality Estimation When estimates are accurate (enough), we make informed decisions around order of operations and physical algorithm selection CE uses a combination of statistical techniques and assumptions During optimization, the cardinality estimation (CE) process is responsible for estimating the number of rows processed at each step in an execution plan

Common reasons for incorrect estimates Missing statistics Stale statistics Inadequate statistics sample rate Bad parameter sniffing scenarios Out-of-model query constructs E.g. MSTVFs, table variables, XQuery Assumptions not aligned with data being queried E.g. independence vs. correlation

Cost of incorrect estimates Slow query response time due to inefficient plans Excessive resource utilization (CPU, Memory, IO) Spills to disk Reduced throughput and concurrency T-SQL refactoring to work around off-model statements

Introducing the new Adaptive Query Processing feature family Interleaved execution Problem: Prior to this feature, MSTVFs are treated as a black box by QP Interleaved Execution will materialize estimates for multi-statement table valued functions (MSTVFs) Downstream operations will benefit from the corrected MSTVF cardinality estimate

Demo: Interleaved execution for MSTVFs

About Interleaved Execution 140 How to enable? Benefits workloads with skews and downstream operations Expected performance improvements?

About Interleaved Execution Minimal, since we’re already materializing MSTVFs Expected overhead? First execution cached will be used by consecutive executions Cached plan considerations Contains Interleaved Execution Candidates Is Interleaved Executed Plan attributes Execution status, CE update, disabled reason Xevents

Introducing the new Adaptive Query Processing feature family Batch-mode memory grant feedback Problem: Queries may spill to disk or take too much memory based on poor cardinality estimates MGF will adjust memory grants based on execution feedback MGF will remove spills and improve concurrency for repeating queries

Demo: Batch-mode memory grant feedback

About Batch Mode Memory Grant Feedback 140 How to enable? Benefits workloads with spills or overages Expected performance improvements? Before After

About Batch Mode Memory Grant Feedback If there is oscillation, we will disable the loop Expected overhead? First execution cached will be used by consecutive executions Plan attributes Spill report, and updates by feedback Xevents For spills – spill size plus a buffer. For overages – waste less the buffer. Expected decrease and increase size? Memory grant size will go back to original. RECOMPILE or eviction scenarios

Introducing the new Adaptive Query Processing feature family Batch-mode adaptive joins Problem: If cardinality estimates are skewed, we may choose an inappropriate join algorithm AJ will defer the choice of hash join or nested loop until after the first join input has been scanned AJ uses nested loop for small inputs, hash joins for large inputs

Demo: Batch-mode adaptive joins

About Batch Mode Adaptive Join How to enable? 140 Compatibility Level Eligible statements The join is eligible to be executed both by an indexed nested loop join or a hash join physical algorithm The hash join uses batch mode – either through the presence of a Columnstore index in the query overall or a Columnstore indexed table being referenced directly by the join The generated alternative solutions of the nested loop join and hash join should have the same first child (outer reference)

Adaptive Join Threshold

About Batch Mode Adaptive Join Expected performance benefit? Performance gains occur for workloads where, prior to adaptive joins being available, the optimizer chooses the wrong join type due to cardinality misestimates

About Batch Mode Adaptive Join We grant memory even for NL scenario, so if NL is * always * optimal, you have more overhead Expected overhead? Adaptive Threshold Rows, Estimated and Actual Join Type Plan attributes Adaptive join skipped Xevents Single compiled plan can accommodate low and high row scenarios Cached plan considerations

Not only for developers….

Not only for developers… CLR security Resumable online index rebuild New DMV’s TSQL Improvements

CLR

Clr security – breaking change A CLR assembly created with PERMISSION_SET = SAFE may be able to access external system resources, call unmanaged code, and acquire sysadmin privileges. Beginning with SQL Server 2017, an sp_configure option called clr strict security is introduced to enhance the security of CLR assemblies. clr strict security is enabled by default, and treats SAFE and EXTERNAL_ACCESS assemblies as if they were marked UNSAFE. After enabling strict security, any assemblies that are not signed will fail to load. You must either alter or drop and recreate each assembly so that it is signed with a certificate or asymmetric key that has a corresponding login with the UNSAFE ASSEMBLY permission on the server. 38 | 11/13/201811/13/2018 | Footer Goes Here

Clr security – breaking change In SQL Server 2017, Microsoft now by default requires that all type of assemblies (SAFE, EXTERNAL_ACCESS, UNSAFE) are authorized for UNSAFE access, by: The database is set to be TRUSTWORTHY, OR The assembly is signed with a certificate that has a corresponding login with UNSAFE ASSEMBLY permission, OR The assembly is signed with an asymmetric key that has a corresponding login with UNSAFE ASSEMBLY permission.

Clr security – breaking change the assembly is not signed, and the database where you want to deploy it to is not TRUSTWORTHY. sys.sp_add_trusted_assembly sys.trusted_assemblies sys.sp_drop_trusted_assembly 40 | 11/13/201811/13/2018 | Footer Goes Here

Resumable online index rebuild Need to cancel the index maintenance operation running out of time in the maintenance period, blocking issues, low disk space due to the transaction log filling up. Resumable Online Index Rebuilds provide the option to pause an index rebuild and provides an option of executing, suspending, resuming or aborting an online index operation. 41 | 11/13/201811/13/2018 | Footer Goes Here

Demo: Resumable index rebuild

Demo: New DMV’s

Demo: T-SQL Improvements