Hidden Gems of SQL Server 2016 Denis Reznik Hidden Gems of SQL Server 2016
Thank you to our AWESOME sponsors!
About Me Denis Reznik Kyiv, Ukraine Data Architect at Intapp, Inc. Microsoft Data Platform MVP Co-Founder of Ukrainian Data Community Kyiv (PASS Chapter) PASS Regional Mentor, Central and Eastern Europe Co-author of “SQL Server MVP Deep Dives vol. 2”
SQL Server 2016 Killer Features Hidden Features Query Store Temporal Tables JSON PolyBase Stretch Database R Services Always Encrypted Hidden Features Statistics Auto-Update Input Buffers Lightweight Profiling Session Waits Functions Stats Query Hints
Statistics Auto-Update
? Statistics SELECT * FROM Users WHERE Id BETWEEN 2100 AND 2500 800 2000 2800 4500 5400
Statistics Auto-Update DEMO Statistics Auto-Update
Statistics Update SQL Server 2014 and lower default behavior: 20% of rows + 500 SQL Server 2016 Dynamic threshold for tables with 25000+ rows TF 2371 for lower versions
Input Buffers
Input Buffers session_id = 65 SELECT * FROM Users WHERE Id = 123 EXEC ReportCheckSecurityRequest @UserId = 1 session_id = 65 SELECT * FROM Users WHERE Id = 123 session_id = 65 Session 65 INPUT BUFFER: EXEC ReportCheckSecurityRequest @UserId = 1 SELECT * FROM Users WHERE Id = 123
DEMO Input Buffers
Lightweight Profiling
Lightweight Profiling SQL Server 2014 – sys.dm_exec_query_profiles SQL Server 2016/2014 SP1 – Live Query Statistics Enable LQS in SSMS SET STATISTICS XML ON SET STATISTICS PROFILE ON query_post_execution_showplan event SQL Server 2016/2014 SP2 - query_thread_profile event SQL Server 2016 SP1 – query_thread_profile/TF 7412 Lightweight query execution profiling https://blogs.msdn.microsoft.com/sql_server_team/query-progress-anytime-anywhere/ Session Level Server Level
Lightweight Profiling DEMO Lightweight Profiling
Session Waits
LCK_M_* Waits Schedulers Runnable Queue Users 2 3 2 1 Suspended Queue Id Name 1 John Snow 2 Peter Partner 3 Jesse Pinkman 4 Jane Dow Id Name 1 John Snow 2 Peter Partner 3 Kirill Nenahov 4 Jane Dow 3 2 1 X S Suspended Queue 1 2 2 LCK_M_X 1 SELECT * FROM Users WHERE Name LIKE 'K%' LCK_M_X 2 UPDATE Users SET Name = 'Jesse Pinkman' WHERE Id = 3
DEMO Session Waits
Functions Stats
Scalar Functions
DEMO Functions Stats
Query Hints
Statistics SELECT * FROM Users u INNER JOIN Posts p ON u.Id = p.OwnerUserId WHERE u.DisplayName LIKE 'Jeff%' Users A G L S T ZZZZ Posts 1 800 2000 2800 4500 5400
DEMO Query Hints
SUMMARY Statistics Auto-Update Input Buffers Lightweight Profiling Session Waits Functions Stats Query Hints
Thank You! Denis Reznik Twitter: @denisreznik Email: denisreznik@gmail.com Blog: http://reznik.uneta.com.ua Facebook: https://www.facebook.com/denis.reznik.5 LinkedIn: http://ua.linkedin.com/pub/denis-reznik/3/502/234