Denis Reznik SQL Server 2017 Hidden Gems
Organizers Natalia Pogorelova Andriy Pogorelov Paul Stetsenko
Sponsors
About Me Denis Reznik Kyiv, Ukraine Data Architect at Intapp, Inc. But Originally from Kharkiv Region 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 2017 Killer Features Hidden Features SQL Server on Linux Graph Database QP Improvements Hidden Features The most “Hidden” feature of SQL Server 2019 Lightweight Profiling File System Views String Aggregation String Trimming Version Store Space Log Statistics Statistics Update/Create CXCONSUMER and CXPACKET waits Functions Troubleshooting Row Goal Compatibility Level
Hidden Features Importance STORY Hidden Features Importance
The most “Hidden” feature of SQL Server 2019 DEMO The most “Hidden” feature of SQL Server 2019
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/ SQL Server 2017 - ? SQL Server 2019 – Enabled by default Session Level Server Level
Lightweight Profiling DEMO Lightweight Profiling
DEMO File System Views
DEMO String Aggregate
DEMO TRIM
Version Store Space
Version Store Usage with SNAPSHOT SELECT * FROM Users WHERE City = 'Kyiv' BEGIN TRAN UPDATE Users SET City = 'Krakow' WHERE City = 'Kyiv' ID City 1 Krakow 2 3 4 5 6 New York 7 ID City 1 Kyiv 2 Krakow 3 4 5 6 New York 7 X SELECT * FROM Users WHERE City = 'Kyiv' Version Store ID City 1 Kyiv tempdb
DEMO Version Store Space
Transaction Log Statistics DEMO Transaction Log Statistics
CXPACKET and CXCONSUMER Waits
CXPACKET and CXCONSUMER Waits DEMO CXPACKET and CXCONSUMER Waits
Parallel Query Execution Amdal’s Law 2s 1s Thread 1 Thread 2 Thread 3 Thread 4
CX_PACKET (<2017) 2s 1s Thread 0 Thread 1 Thread 2 Thread 3 CXPACKET Wait CXPACKET Wait Thread 1 CXPACKET Wait Thread 2 CXPACKET Wait Thread 3 Thread 4 CXPACKET Wait
CX_PACKET 2017 2s 1s Thread 0 Thread 1 Thread 2 Thread 3 Thread 4 CXCONSUMER Wait CXCONSUMER Wait Thread 1 CXPACKET Wait Thread 2 CXPACKET Wait Thread 3 Thread 4 CXPACKET Wait
Functions Troubleshooting DEMO Functions Troubleshooting
DEMO Row Goal
QUERY OPTIMIZER COMPATIBILITY LEVEL
Statistics SELECT * FROM Users WHERE Id BETWEEN 2100 AND 2500 800 2000 2800 4500 5400
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
QUERY OPTIMIZER COMPATIBILITY LEVEL DEMO QUERY OPTIMIZER COMPATIBILITY LEVEL
SUMMARY Hidden Features Importance Story Truncation Error Message (the most known “hidden” feature) Lightweight Profiling File System Views String Aggregation String Trimming Version Store Space Log Statistics Statistics Update/Create CXCONSUMER and CXPACKET waits Functions Troubleshooting Row Goal Compatibility Level
Sponsors
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