SlideShare a Scribd company logo
1 of 29
Download to read offline
Grant Fritchey | www.ScaryDBA.com
www.ScaryDBA.com
SQL Server Optimization
Checklist
Grant Fritchey
Product Evangelist
Red Gate Software
Grant Fritchey | www.ScaryDBA.com
Agenda
 Server Configuration
 SQL Server Administration
 Database Design
 TSQL Coding
2
Grant Fritchey | www.ScaryDBA.com
Get it Touch
3
scarydba.com
grant@scarydba.com
@gfritchey
Grant Fritchey | www.ScaryDBA.com
Test
Test
Test
Test
Test
4
Grant Fritchey | www.ScaryDBA.com
Remember
 This is focused on performance tuning
5
Grant Fritchey | www.ScaryDBA.com
Remember
 This is focused on performance tuning
6
There are always exceptions
Grant Fritchey | www.ScaryDBA.com
Remember
 This is focused on performance tuning
 There are always exceptions
7
Your hardware may be DIFFERENT
Grant Fritchey | www.ScaryDBA.com
Remember
 This is focused on performance tuning
 There are always exceptions
 Your hardware may be different
8
Did I mention test?
Grant Fritchey | www.ScaryDBA.com
Remember
 This is focused on performance tuning
 There are always exceptions
 Your hardware may be different
 Did I mention test?
9
In
cre
men
tal changes
Grant Fritchey | www.ScaryDBA.com
Remember
 This is focused on performance tuning
 There are always exceptions
 Your hardware may be different
 Did I mention test?
 Incremental changes
10
onitoryour servers
Grant Fritchey | www.ScaryDBA.com
Remember
 This is focused on performance tuning
 There are always exceptions
 Your hardware may be different
 Did I mention test?
 Incremental changes
 Monitor your servers
11
I am NOT a systems expert
Grant Fritchey | www.ScaryDBA.com
Remember
 This is focused on performance tuning
 There are always exceptions
 Your hardware may be different
 Did I mention test?
 Incremental changes
 Monitor your servers
 I am not a systems expert
12
You might want toTEST
Grant Fritchey | www.ScaryDBA.com
Remember
 This is focused on performance tuning
 There are always exceptions
 Your hardware may be different
 Did I mention test?
 Incremental changes
 Monitor your servers
 I am not a systems expert
 You might want to test
13
Grant Fritchey | www.ScaryDBA.com
Server Configuration
14
Memory CPU Disks
Grant Fritchey | www.ScaryDBA.com
SQL Server Configuration:
Memory
 >4g enable AWE
» On 2008R2 or less
» On 32-bit systems
 Dynamic
» but set a minimum and a maximum value
 Optimize for Ad HocWorkloads
» Enable on all servers
15
Grant Fritchey | www.ScaryDBA.com
SQL Server Configuration:
CPU
 CostThreshold for parallelism
» 5, the default, is too low
» OLTP = 40
» Reporting = 25
 Max Degree of Parallelism
» Leave it on, after you change the cost threshold
 Consider using Query Governor
» Set a cost limit
16
Grant Fritchey | www.ScaryDBA.com
SQL Server Configuration:
Storage
 TEMPDB
» Separate from other data when possible
» Multiple Files
— Not equal to #of processors
— Equal sized files
 Compression
» Minimum, index compression
 More disks is better
» But only if you have more controllers
 Spend money
» Buy faster disks
17
Grant Fritchey | www.ScaryDBA.com
SQL Server
Administration
 Maintain Statistics
» Enable AUTO_CREATE & AUTO_UPDATE
» You must also plan for manual updates
» You may need FULL SCAN
» Consider ASYNC
 Defragment your indexes
» Number of pages does matter
» You can defrag below 1000 pages
» You can’t defrag below 8 pages
» Separate defrag & statistics updates
18
Grant Fritchey | www.ScaryDBA.com
SQL Server
Administration 2
 Avoid dangerous settings
» Disable AUTO_CLOSE
» Disable AUTO_SHRINK
 Do not use the Profiler GUI on production systems
» Create a server-side trace usingTSQL scripts
(prior to 2008)
» Use extended events
— Consider for 2008 or better
— Absolutely for 2012 or better
 Set Blocked ProcessThreshold
» Based on your system
19
Grant Fritchey | www.ScaryDBA.com
Database Design
 Storage
 Constraints
 Indexes
20
Grant Fritchey | www.ScaryDBA.com
Database Design: Storage
 Separate Log & Data
 Multiple File Groups
» Even on a single drive
 Turn off auto-grow
» If not possible, used fixed growth, not percentage
 Consider In-Memory
» 2014 only
» I/O Latch waits
21
Grant Fritchey | www.ScaryDBA.com
Database Design:
Constraints
 Normalize your Data
» Normalization benefits performance
 Enforce Constraints
» Foreign keys
» Primary keys
» Unique values
22
Grant Fritchey | www.ScaryDBA.com
Database Design: Indexes -
General
 Narrow
» As narrow as possible
 Integers
» Believe it or not, they’re better
 Choose leading edge carefully
» Most selective column
 Covering Indexes are fastest
» Use INCLUDE
23
Grant Fritchey | www.ScaryDBA.com
Database Design: Indexes -
Clustered
 Again, Narrow
» As narrow as possible
 Design around the clustered index
» Most frequent used path to data
 Rebuilding clustered index
» Use DROP_EXISTING
 Avoid columns that get updated frequently
» This means all non-clustered indexes are updated
too
24
Grant Fritchey | www.ScaryDBA.com
TSQL Coding
 Return only the data you need, when you need it
 Use stored procedures or parameterized queries
» Encourages plan reuse
» Prevents SQL Injection
 Avoid cursors,WHILE, LOOP
» Row By Agonizing Row style processing
 Qualify all object names
» Reduces lookup costs
 Avoid using ‘sp_*’ for procedure names
» Eliminates additional read to the master database
25
Grant Fritchey | www.ScaryDBA.com
TSQL Coding 2
 Avoid nonsargeable conditions
» Meaning functions on columns
» Or, using LIKE ‘%Anything’
 Use SET NOCOUNT ON
» Reduces returns on network
 Do not nest views
» Or join them. It confuses the optimizer
 Don’t use optimizer hints
» More often than not it causes problems
» Especially NOLOCK
26
Grant Fritchey | www.ScaryDBA.com
TSQL Coding 3
 Avoid Recompiling Execution Plans
» Stored procedures & parameterized queries
» Table variables instead of temp tables
» ANSI standards on connection settings
— And Don’t change them within a query
» Don’t interleave DDL & DML
 Adopt best practices for transactions
» Keep scope as short as possible
» Use SET XACT_ABORT
» Consider using READ COMMITTED SNAPSHOT
27
Grant Fritchey | www.ScaryDBA.com
Relax
 It’s not that bad
 Most things can be changed
 Help is available
 Test everything
28
Grant Fritchey | www.ScaryDBA.com
Questions?
29

More Related Content

What's hot

Oracle performance tuning_sfsf
Oracle performance tuning_sfsfOracle performance tuning_sfsf
Oracle performance tuning_sfsf
Mao Geng
 
Fatkulin hotsos 2014
Fatkulin hotsos 2014Fatkulin hotsos 2014
Fatkulin hotsos 2014
Enkitec
 
Oracle Oracle Performance Tuning
Oracle Oracle Performance Tuning Oracle Oracle Performance Tuning
Oracle Oracle Performance Tuning
Kernel Training
 

What's hot (20)

Query Optimization in SQL Server
Query Optimization in SQL ServerQuery Optimization in SQL Server
Query Optimization in SQL Server
 
Performance tuning in sql server
Performance tuning in sql serverPerformance tuning in sql server
Performance tuning in sql server
 
Sql Server Performance Tuning
Sql Server Performance TuningSql Server Performance Tuning
Sql Server Performance Tuning
 
SQL Server Query Optimization, Execution and Debugging Query Performance
SQL Server Query Optimization, Execution and Debugging Query PerformanceSQL Server Query Optimization, Execution and Debugging Query Performance
SQL Server Query Optimization, Execution and Debugging Query Performance
 
Database Performance Tuning
Database Performance Tuning Database Performance Tuning
Database Performance Tuning
 
SQL Server Performance Tuning Baseline
SQL Server Performance Tuning BaselineSQL Server Performance Tuning Baseline
SQL Server Performance Tuning Baseline
 
Inside SQL Server In-Memory OLTP
Inside SQL Server In-Memory OLTPInside SQL Server In-Memory OLTP
Inside SQL Server In-Memory OLTP
 
Oracle performance tuning_sfsf
Oracle performance tuning_sfsfOracle performance tuning_sfsf
Oracle performance tuning_sfsf
 
Sql server 2016 it just runs faster sql bits 2017 edition
Sql server 2016 it just runs faster   sql bits 2017 editionSql server 2016 it just runs faster   sql bits 2017 edition
Sql server 2016 it just runs faster sql bits 2017 edition
 
SQL Server Wait Types Everyone Should Know
SQL Server Wait Types Everyone Should KnowSQL Server Wait Types Everyone Should Know
SQL Server Wait Types Everyone Should Know
 
SQL Server In-Memory OLTP: What Every SQL Professional Should Know
SQL Server In-Memory OLTP: What Every SQL Professional Should KnowSQL Server In-Memory OLTP: What Every SQL Professional Should Know
SQL Server In-Memory OLTP: What Every SQL Professional Should Know
 
Performance Tuning And Optimization Microsoft SQL Database
Performance Tuning And Optimization Microsoft SQL DatabasePerformance Tuning And Optimization Microsoft SQL Database
Performance Tuning And Optimization Microsoft SQL Database
 
Fatkulin hotsos 2014
Fatkulin hotsos 2014Fatkulin hotsos 2014
Fatkulin hotsos 2014
 
Enhancements that will make your sql database roar sp1 edition sql bits 2017
Enhancements that will make your sql database roar sp1 edition sql bits 2017Enhancements that will make your sql database roar sp1 edition sql bits 2017
Enhancements that will make your sql database roar sp1 edition sql bits 2017
 
Experience sql server on l inux and docker
Experience sql server on l inux and dockerExperience sql server on l inux and docker
Experience sql server on l inux and docker
 
SQL Server R Services: What Every SQL Professional Should Know
SQL Server R Services: What Every SQL Professional Should KnowSQL Server R Services: What Every SQL Professional Should Know
SQL Server R Services: What Every SQL Professional Should Know
 
SQL Server It Just Runs Faster
SQL Server It Just Runs FasterSQL Server It Just Runs Faster
SQL Server It Just Runs Faster
 
Oracle Oracle Performance Tuning
Oracle Oracle Performance Tuning Oracle Oracle Performance Tuning
Oracle Oracle Performance Tuning
 
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentalsDB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
 
Oracle Database Performance Tuning Basics
Oracle Database Performance Tuning BasicsOracle Database Performance Tuning Basics
Oracle Database Performance Tuning Basics
 

Similar to SQL Server Optimization Checklist

Analysis Services Best Practices From Large Deployments
Analysis Services   Best Practices From Large DeploymentsAnalysis Services   Best Practices From Large Deployments
Analysis Services Best Practices From Large Deployments
rsnarayanan
 
Strata + Hadoop 2015 Slides
Strata + Hadoop 2015 SlidesStrata + Hadoop 2015 Slides
Strata + Hadoop 2015 Slides
Jun Liu
 
Geek Sync | Top 10 SQL Server Performance Makers and Breakers
Geek Sync | Top 10 SQL Server Performance Makers and BreakersGeek Sync | Top 10 SQL Server Performance Makers and Breakers
Geek Sync | Top 10 SQL Server Performance Makers and Breakers
IDERA Software
 

Similar to SQL Server Optimization Checklist (20)

Changing Your Habits: Tips to Tune Your T-SQL
Changing Your Habits: Tips to Tune Your T-SQLChanging Your Habits: Tips to Tune Your T-SQL
Changing Your Habits: Tips to Tune Your T-SQL
 
Introducing Azure SQL Data Warehouse
Introducing Azure SQL Data WarehouseIntroducing Azure SQL Data Warehouse
Introducing Azure SQL Data Warehouse
 
Top Tips for Better T-SQL
Top Tips for Better T-SQLTop Tips for Better T-SQL
Top Tips for Better T-SQL
 
Why new hardware may not make SQL Server faster
Why new hardware may not make SQL Server fasterWhy new hardware may not make SQL Server faster
Why new hardware may not make SQL Server faster
 
Query Tuning Azure SQL Databases
Query Tuning Azure SQL DatabasesQuery Tuning Azure SQL Databases
Query Tuning Azure SQL Databases
 
Grant Fritchey - Query Tuning In Azure SQL Database
Grant Fritchey - Query Tuning In Azure SQL DatabaseGrant Fritchey - Query Tuning In Azure SQL Database
Grant Fritchey - Query Tuning In Azure SQL Database
 
Dynamics ax performance tuning
Dynamics ax performance tuningDynamics ax performance tuning
Dynamics ax performance tuning
 
Azure SQL Database for the Earthed DBA
Azure SQL Database for the Earthed DBAAzure SQL Database for the Earthed DBA
Azure SQL Database for the Earthed DBA
 
Analysis Services Best Practices From Large Deployments
Analysis Services   Best Practices From Large DeploymentsAnalysis Services   Best Practices From Large Deployments
Analysis Services Best Practices From Large Deployments
 
Pro Techniques for the SSASMD Developer
Pro Techniques for the SSASMD DeveloperPro Techniques for the SSASMD Developer
Pro Techniques for the SSASMD Developer
 
Common SQL Server Mistakes and How to Avoid Them with Tim Radney
Common SQL Server Mistakes and How to Avoid Them with Tim RadneyCommon SQL Server Mistakes and How to Avoid Them with Tim Radney
Common SQL Server Mistakes and How to Avoid Them with Tim Radney
 
GOTO 2013: Why Zalando trusts in PostgreSQL
GOTO 2013: Why Zalando trusts in PostgreSQLGOTO 2013: Why Zalando trusts in PostgreSQL
GOTO 2013: Why Zalando trusts in PostgreSQL
 
Strata + Hadoop 2015 Slides
Strata + Hadoop 2015 SlidesStrata + Hadoop 2015 Slides
Strata + Hadoop 2015 Slides
 
Geek Sync | Top 10 SQL Server Performance Makers and Breakers
Geek Sync | Top 10 SQL Server Performance Makers and BreakersGeek Sync | Top 10 SQL Server Performance Makers and Breakers
Geek Sync | Top 10 SQL Server Performance Makers and Breakers
 
Configuring sql server - SQL Saturday, Athens Oct 2014
Configuring sql server - SQL Saturday, Athens Oct 2014Configuring sql server - SQL Saturday, Athens Oct 2014
Configuring sql server - SQL Saturday, Athens Oct 2014
 
PGDay India 2016
PGDay India 2016PGDay India 2016
PGDay India 2016
 
Performance tuning Grails applications SpringOne 2GX 2014
Performance tuning Grails applications SpringOne 2GX 2014Performance tuning Grails applications SpringOne 2GX 2014
Performance tuning Grails applications SpringOne 2GX 2014
 
Cloudforms Workshop
Cloudforms WorkshopCloudforms Workshop
Cloudforms Workshop
 
Database continuous integration, unit test and functional test
Database continuous integration, unit test and functional testDatabase continuous integration, unit test and functional test
Database continuous integration, unit test and functional test
 
Optimizing Python
Optimizing PythonOptimizing Python
Optimizing Python
 

More from Grant Fritchey

More from Grant Fritchey (20)

Migrating To PostgreSQL
Migrating To PostgreSQLMigrating To PostgreSQL
Migrating To PostgreSQL
 
PostgreSQL Performance Problems: Monitoring and Alerting
PostgreSQL Performance Problems: Monitoring and AlertingPostgreSQL Performance Problems: Monitoring and Alerting
PostgreSQL Performance Problems: Monitoring and Alerting
 
Automating Database Deployments Using Azure DevOps
Automating Database Deployments Using Azure DevOpsAutomating Database Deployments Using Azure DevOps
Automating Database Deployments Using Azure DevOps
 
Learn To Effectively Use Extended Events_Techorama.pdf
Learn To Effectively Use Extended Events_Techorama.pdfLearn To Effectively Use Extended Events_Techorama.pdf
Learn To Effectively Use Extended Events_Techorama.pdf
 
Using Query Store to Understand and Control Query Performance
Using Query Store to Understand and Control Query PerformanceUsing Query Store to Understand and Control Query Performance
Using Query Store to Understand and Control Query Performance
 
You Should Be Standing Here: Learn How To Present a Session
You Should Be Standing Here: Learn How To Present a SessionYou Should Be Standing Here: Learn How To Present a Session
You Should Be Standing Here: Learn How To Present a Session
 
Redgate Community Circle: Tools For SQL Server Performance Tuning
Redgate Community Circle: Tools For SQL Server Performance TuningRedgate Community Circle: Tools For SQL Server Performance Tuning
Redgate Community Circle: Tools For SQL Server Performance Tuning
 
10 Steps To Global Data Compliance
10 Steps To Global Data Compliance10 Steps To Global Data Compliance
10 Steps To Global Data Compliance
 
Time to Use the Columnstore Index
Time to Use the Columnstore IndexTime to Use the Columnstore Index
Time to Use the Columnstore Index
 
Introduction to SQL Server in Containers
Introduction to SQL Server in ContainersIntroduction to SQL Server in Containers
Introduction to SQL Server in Containers
 
DevOps for the DBA
DevOps for the DBADevOps for the DBA
DevOps for the DBA
 
SQL Injection: How It Works, How to Stop It
SQL Injection: How It Works, How to Stop ItSQL Injection: How It Works, How to Stop It
SQL Injection: How It Works, How to Stop It
 
Privacy and Protection in the World of Database DevOps
Privacy and Protection in the World of Database DevOpsPrivacy and Protection in the World of Database DevOps
Privacy and Protection in the World of Database DevOps
 
SQL Server Tools for Query Tuning
SQL Server Tools for Query TuningSQL Server Tools for Query Tuning
SQL Server Tools for Query Tuning
 
Extending DevOps to SQL Server
Extending DevOps to SQL ServerExtending DevOps to SQL Server
Extending DevOps to SQL Server
 
Introducing Azure Databases
Introducing Azure DatabasesIntroducing Azure Databases
Introducing Azure Databases
 
Statistis, Row Counts, Execution Plans and Query Tuning
Statistis, Row Counts, Execution Plans and Query TuningStatistis, Row Counts, Execution Plans and Query Tuning
Statistis, Row Counts, Execution Plans and Query Tuning
 
Understanding Your Servers, All Your Servers
Understanding Your Servers, All Your ServersUnderstanding Your Servers, All Your Servers
Understanding Your Servers, All Your Servers
 
The Query Store SQL Tuning
The Query Store SQL TuningThe Query Store SQL Tuning
The Query Store SQL Tuning
 
Performance Tuning Azure SQL Database
Performance Tuning Azure SQL DatabasePerformance Tuning Azure SQL Database
Performance Tuning Azure SQL Database
 

Recently uploaded

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Recently uploaded (20)

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 

SQL Server Optimization Checklist

  • 1. Grant Fritchey | www.ScaryDBA.com www.ScaryDBA.com SQL Server Optimization Checklist Grant Fritchey Product Evangelist Red Gate Software
  • 2. Grant Fritchey | www.ScaryDBA.com Agenda  Server Configuration  SQL Server Administration  Database Design  TSQL Coding 2
  • 3. Grant Fritchey | www.ScaryDBA.com Get it Touch 3 scarydba.com grant@scarydba.com @gfritchey
  • 4. Grant Fritchey | www.ScaryDBA.com Test Test Test Test Test 4
  • 5. Grant Fritchey | www.ScaryDBA.com Remember  This is focused on performance tuning 5
  • 6. Grant Fritchey | www.ScaryDBA.com Remember  This is focused on performance tuning 6 There are always exceptions
  • 7. Grant Fritchey | www.ScaryDBA.com Remember  This is focused on performance tuning  There are always exceptions 7 Your hardware may be DIFFERENT
  • 8. Grant Fritchey | www.ScaryDBA.com Remember  This is focused on performance tuning  There are always exceptions  Your hardware may be different 8 Did I mention test?
  • 9. Grant Fritchey | www.ScaryDBA.com Remember  This is focused on performance tuning  There are always exceptions  Your hardware may be different  Did I mention test? 9 In cre men tal changes
  • 10. Grant Fritchey | www.ScaryDBA.com Remember  This is focused on performance tuning  There are always exceptions  Your hardware may be different  Did I mention test?  Incremental changes 10 onitoryour servers
  • 11. Grant Fritchey | www.ScaryDBA.com Remember  This is focused on performance tuning  There are always exceptions  Your hardware may be different  Did I mention test?  Incremental changes  Monitor your servers 11 I am NOT a systems expert
  • 12. Grant Fritchey | www.ScaryDBA.com Remember  This is focused on performance tuning  There are always exceptions  Your hardware may be different  Did I mention test?  Incremental changes  Monitor your servers  I am not a systems expert 12 You might want toTEST
  • 13. Grant Fritchey | www.ScaryDBA.com Remember  This is focused on performance tuning  There are always exceptions  Your hardware may be different  Did I mention test?  Incremental changes  Monitor your servers  I am not a systems expert  You might want to test 13
  • 14. Grant Fritchey | www.ScaryDBA.com Server Configuration 14 Memory CPU Disks
  • 15. Grant Fritchey | www.ScaryDBA.com SQL Server Configuration: Memory  >4g enable AWE » On 2008R2 or less » On 32-bit systems  Dynamic » but set a minimum and a maximum value  Optimize for Ad HocWorkloads » Enable on all servers 15
  • 16. Grant Fritchey | www.ScaryDBA.com SQL Server Configuration: CPU  CostThreshold for parallelism » 5, the default, is too low » OLTP = 40 » Reporting = 25  Max Degree of Parallelism » Leave it on, after you change the cost threshold  Consider using Query Governor » Set a cost limit 16
  • 17. Grant Fritchey | www.ScaryDBA.com SQL Server Configuration: Storage  TEMPDB » Separate from other data when possible » Multiple Files — Not equal to #of processors — Equal sized files  Compression » Minimum, index compression  More disks is better » But only if you have more controllers  Spend money » Buy faster disks 17
  • 18. Grant Fritchey | www.ScaryDBA.com SQL Server Administration  Maintain Statistics » Enable AUTO_CREATE & AUTO_UPDATE » You must also plan for manual updates » You may need FULL SCAN » Consider ASYNC  Defragment your indexes » Number of pages does matter » You can defrag below 1000 pages » You can’t defrag below 8 pages » Separate defrag & statistics updates 18
  • 19. Grant Fritchey | www.ScaryDBA.com SQL Server Administration 2  Avoid dangerous settings » Disable AUTO_CLOSE » Disable AUTO_SHRINK  Do not use the Profiler GUI on production systems » Create a server-side trace usingTSQL scripts (prior to 2008) » Use extended events — Consider for 2008 or better — Absolutely for 2012 or better  Set Blocked ProcessThreshold » Based on your system 19
  • 20. Grant Fritchey | www.ScaryDBA.com Database Design  Storage  Constraints  Indexes 20
  • 21. Grant Fritchey | www.ScaryDBA.com Database Design: Storage  Separate Log & Data  Multiple File Groups » Even on a single drive  Turn off auto-grow » If not possible, used fixed growth, not percentage  Consider In-Memory » 2014 only » I/O Latch waits 21
  • 22. Grant Fritchey | www.ScaryDBA.com Database Design: Constraints  Normalize your Data » Normalization benefits performance  Enforce Constraints » Foreign keys » Primary keys » Unique values 22
  • 23. Grant Fritchey | www.ScaryDBA.com Database Design: Indexes - General  Narrow » As narrow as possible  Integers » Believe it or not, they’re better  Choose leading edge carefully » Most selective column  Covering Indexes are fastest » Use INCLUDE 23
  • 24. Grant Fritchey | www.ScaryDBA.com Database Design: Indexes - Clustered  Again, Narrow » As narrow as possible  Design around the clustered index » Most frequent used path to data  Rebuilding clustered index » Use DROP_EXISTING  Avoid columns that get updated frequently » This means all non-clustered indexes are updated too 24
  • 25. Grant Fritchey | www.ScaryDBA.com TSQL Coding  Return only the data you need, when you need it  Use stored procedures or parameterized queries » Encourages plan reuse » Prevents SQL Injection  Avoid cursors,WHILE, LOOP » Row By Agonizing Row style processing  Qualify all object names » Reduces lookup costs  Avoid using ‘sp_*’ for procedure names » Eliminates additional read to the master database 25
  • 26. Grant Fritchey | www.ScaryDBA.com TSQL Coding 2  Avoid nonsargeable conditions » Meaning functions on columns » Or, using LIKE ‘%Anything’  Use SET NOCOUNT ON » Reduces returns on network  Do not nest views » Or join them. It confuses the optimizer  Don’t use optimizer hints » More often than not it causes problems » Especially NOLOCK 26
  • 27. Grant Fritchey | www.ScaryDBA.com TSQL Coding 3  Avoid Recompiling Execution Plans » Stored procedures & parameterized queries » Table variables instead of temp tables » ANSI standards on connection settings — And Don’t change them within a query » Don’t interleave DDL & DML  Adopt best practices for transactions » Keep scope as short as possible » Use SET XACT_ABORT » Consider using READ COMMITTED SNAPSHOT 27
  • 28. Grant Fritchey | www.ScaryDBA.com Relax  It’s not that bad  Most things can be changed  Help is available  Test everything 28
  • 29. Grant Fritchey | www.ScaryDBA.com Questions? 29