One of the most common issues with a SQL Server environment is the occasions where the queries run on it are running slower than usual. When this happens; there will be bottlenecks to production jobs and decision making data generation.
Here are 7 potential fixes for SQL Server slow query issues:
- Create and Optimize Indexes
- Add missing indexes (use
Database Engine Tuning Advisororsys.dm_db_missing_index_details). - Reduce overhead costs by dropping duplicate or unneeded indexes.
- Add missing indexes (use
- Update Statistics
- Run
UPDATE STATISTICSor enableAUTO_UPDATE_STATISTICSto ensure the query optimizer has accurate data distribution.
- Run
- Rewrite Queries
- Avoid
SELECT *. - Break complex joins up into smaller queries.
- Reduce row scans by filtering properly (
WHERE).
- Avoid
- Use Execution plans for Diagnosis
- Analyze actual execution plans using SSMS in order to detect scans, key looksups, and operators that cause performance hits.
- Reduce Parameter Sniffing Issues
- Use
OPTION (RECOMPILE)for problematic queries. - Use
OPTIMIZE FOR UNKNOWNtips when parameter values vary widely.
- Use
- Optimize TempDB Usage
- Add multiple TempDB data files (same size).
- Use fast storage with TF1117/1118 (pre SQL 2016 SP1, now defaults), to reduce allocation contention.
- Review Server Configuration
- Set
MAXDOPto the appropriate value (generally MAXDOP is / #CPUs/ NUMA nodes ). - Set
Threshold Cost for ParallelismHigher than default (default is 5).
- Set
Leave a Reply