Successfully reported this slideshow.
Your SlideShare is downloading. ×

Tarabica 2019 (Belgrade, Serbia) - SQL Server performance troubleshooting

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 24 Ad

Tarabica 2019 (Belgrade, Serbia) - SQL Server performance troubleshooting

Download to read offline

Finding and fixing performance issues in SQL Server and the Azure SQL database requires understanding how database engine works and what can affect performance. People sometime make changes without finding the exact cause of the problem, which causes additional issues in the future. In this presentation, we will see some techniques you can apply to identify problems and solutions using Query Store technology, DMVs, SQL plan analysis, etc.
https://www.tarabica.org/Session/Details/78

Finding and fixing performance issues in SQL Server and the Azure SQL database requires understanding how database engine works and what can affect performance. People sometime make changes without finding the exact cause of the problem, which causes additional issues in the future. In this presentation, we will see some techniques you can apply to identify problems and solutions using Query Store technology, DMVs, SQL plan analysis, etc.
https://www.tarabica.org/Session/Details/78

Advertisement
Advertisement

More Related Content

Slideshows for you (20)

Similar to Tarabica 2019 (Belgrade, Serbia) - SQL Server performance troubleshooting (20)

Advertisement

Tarabica 2019 (Belgrade, Serbia) - SQL Server performance troubleshooting

  1. 1. Performance troubleshooting Azure SQL & SQL Server
  2. 2. Jovan Popovic Program manager Microsoft SQL Server/Azure Azure/SQL/ASP.NET/Jquery PhD Electrical Engineering Sinergija, Tarabica, PassSummit, SqlBits, SqlKonferenz, SqlSaturday,…
  3. 3. Agenda • Maintenance • Monitoring usage • Identify issues with wait statistics • Troubleshoot query plans • Tools • Blitz • BPCHECK • QPI • ODS • DbaTools
  4. 4. Maintaining the instance • Is your instance properly configured? • TEMPDB, backups • Are there any issues in databases? • Tools • First Responder Kit • BPCHECK
  5. 5. Sp_Blitz (First Responder Kit) - sp_Blitz.sql - https://www.brentozar.com/blitz/ EXEC [dbo].[sp_Blitz] @CheckUserDatabaseObjects = 1 , @CheckProcedureCache = 0 , @OutputType = 'TABLE' , @OutputProcedureCache = 0 , @CheckProcedureCacheFilter = NULL, @CheckServerInfo = 1
  6. 6. Sp_blitz results • Last good DBCC CHECKDB over 2 weeks old • Many Plans for One Query • 170 plans are present for a single query in the plan cache - meaning we probably have parameterization issues. • Cost threshold for parallelism • Set to 5, its default value. Changing this sp_configure setting may reduce CXPACKET waits. • Max degree of parallelism • Set to 0, its default value. Changing this sp_configure setting may reduce CXPACKET waits.
  7. 7. DBCC CHECKDB • Options • NOINDEX - Specifies that intensive checks of nonclustered indexes for user tables should not be performed. This decreases the overall execution time. NOINDEX does not affect system tables because integrity checks are always performed on system table indexes. • PHYSICAL_ONLY - Limits the checking to the integrity of the physical structure of the page and record headers and the allocation consistency of the database. This check is designed to provide a small overhead check of the physical consistency of the database, but it can also detect torn pages, checksum failures, and common hardware failures that can compromise a user's data. • TABLOCK - Causes DBCC CHECKDB to obtain locks instead of using an internal database snapshot. This includes a short-term exclusive (X) lock on the database. TABLOCK will cause DBCC CHECKDB to run faster on a database under heavy load, but decreases the concurrency available on the database while DBCC CHECKDB is running. • DATA_PURITY - Causes DBCC CHECKDB to check the database for column values that are not valid or out-of-range. For example, DBCC CHECKDB detects columns with date and time values that are larger than or less than the acceptable range for the datetime data type; or decimal or approximate-numeric data type columns with scale or precision values that are not valid. • Repair options • REPAIR_ALLOW_DATA_LOSS - Tries to repair all reported errors. These repairs can cause some data loss. • REPAIR_REBUILD - Performs repairs that have no possibility of data loss. This can include quick repairs, such as repairing missing rows in non-clustered indexes, and more time-consuming repairs, such as rebuilding an index.
  8. 8. SqlTiger Maintenance solution • http://aka.ms/MaintenanceSolution • Weekly DBCC CHECKDB on all online, read-write user databases below 1TB. • Daily combination of DBCC CHECKALLOC, DBCC CHECKCATALOG, DBCC CHECKTABLE (depending on VLDB setting) on all online, read-write user databases over 1TB. • Weekly execution of DBCC UPDATEUSAGE on all online, read-write databases up to 4GB. • Weekly execution of sp_createstats with indexonly. • Weekly purge of all MSDB job history over 30d. • Weekly purge of all maintenance plan text reports over 30d (if you are still using package based maintenance plans).
  9. 9. SqlTiger BPCHECK • Check_BP_Servers.sql EXEC usp_bpcheck @custompath, @dbScope, @allow_xpcmdshell, @ptochecks, @duration, @logdetail, @diskfrag, @ixfrag, @ixfragscanmode, @bpool_consumer, @spn_check, @gen_scripts
  10. 10. Bpcheck results
  11. 11. Other tools • sp_BlitzWho: What Queries are Running Now • sp_BlitzCache: Most Resource-Intensive Queries • sp_BlitzQueryStore: Most Resource-Intensive Queries in history • sp_BlitzFirst: Real-Time Performance Advice • More on • https://github.com/microsoft/tigertoolbox • https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit
  12. 12. PsDbaTools
  13. 13. Index & Statistics Maintenance • Create missing indexes • Azure SQL Database automatic tuning • SSMS, spBlitzIndex • Rebuild/reorganize defragmented indexes • Olla Hallengren, SqlTiger • Drop duplicate indexes • First Responder Kit • Create statistics • Update statistics • Maintenance solution
  14. 14. Index maintenance
  15. 15. Index Maintenance • Ola Hallengren Index Maintenance • Sql Tiger Adaptive Index Defrag or Maintenance Solution • Azure SQL Database AUTOMATIC_TUNING (CREATE_INDEX, DROP_INDEX) • sp_BlitzIndex
  16. 16. Performance troubleshooting
  17. 17. Why is my query running slow? • Not enough CPU? • Not enough memory? • Too much IO? • TempDB spill? • Cardinality estimate? • Wrong plan? • Waiting some other query (blocked)?
  18. 18. What to check? • Is there CPU, memory, IO pressure? • Why the plan is waiting? Is it blocked? • Is the plan changed? Is it slower?
  19. 19. SSMS reports
  20. 20. SSMS Query Store
  21. 21. Query processing https://rusanu.com/2013/08/01/understanding-how-sql-server-executes-a-query/
  22. 22. Thread lifecycle Running WaitSignal
  23. 23. Demo
  24. 24. Conclusion • Identify root cause • Ensure that server is fine • Check resource usage • Check query plan • Check wait statistics & blockings

×