Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "SQL Server 2017 has more cool features than just running on Linux"— Presentation transcript:

1 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

2 Sponsors

3 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!

4 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

5 Damian Widera 15+ years of experience with SQL Server
Data Platform MVP & MCT Microsoft Certified Solutions Expert Data Management and Analytics Business Intelligence

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

7 Automated Tuning and wait statistics in Query Store

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

9 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

10 Demo: Wait statistics in Query Store

11 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

12 Demo: Automated Tuning

13 Adaptive Query Processing

14 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

15 MSTVF execution plan example

16 Example “problem” query

17 MSTVF definition

18 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

19 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

20 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

21 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

22 Demo: Interleaved execution for MSTVFs

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

24 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

25 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

26 Demo: Batch-mode memory grant feedback

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

28 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

29 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

30 Demo: Batch-mode adaptive joins

31 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)

32 Adaptive Join Threshold

33 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

34 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

35 Not only for developers….

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

37 CLR

38 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

39 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.

40 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

41 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

42 Demo: Resumable index rebuild

43 Demo: New DMV’s

44 Demo: T-SQL Improvements


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

Similar presentations


Ads by Google