SlideShare une entreprise Scribd logo
1  sur  33
Télécharger pour lire hors ligne
Brad M. McGehee
SQL Server MVP
Director of DBA Education
Red Gate Software
 You may be a part-time or full-time DBA
 You may be a DBA Administrator or DBA
Developer
 You may have less than one year’s experience as
a SQL Server DBA
 You may be an experienced DBA, but don’t mind
spending a little time reviewing DBA
fundamentals, because you may learn something
new, or remind you of something you forgot.
 Helps to optimize SQL Server performance
 Helps to maximum SQL Server availability
 Helps you to be proactive, not reactive
 Helps you to reduce being in “crisis” mode
 Reduces your stress levels
 Makes your manager happier
 Give you more time to focus on what really
interests you
 While each best practice I discuss today might
seem small, the total effect of following each and
every recommendation can be huge.
 By closely following each of these best practices,
SQL Server performance and availability can be
boosted by 20%, 50%, or even more.
 Check &Verify
 One-time checks to verify proper SQL Server instance
configuration
 On-GoingTasks
 Daily, weekly, monthly tasks that need on-going attention
1. Our focus today is on what to do, not how to do it.
2. Best practices are based on the biggest mistakes I see DBAs make.
3. These best practices are just the basics, there are a lot more to learn.
4. There are always exceptions to every rule, and not every recommendation
discussed here may fit your environment.
 Installing & Upgrading SQL Server
 General Configuration
 Memory Configuration
 User Data and Log File Management
 Tempdb Management
 Database Configuration Settings
 Configuring Jobs—General
 Create Index Rebuilding/Reorganize Job
 Create Data Corruption Detection Job
 Set Up Alerts for Critical Errors
 Security Basics
 Implement a Backup Strategy
 Create a Disaster Recovery Plan
 Test Everything
 When installing a new SQL Server instance:
 Use the newest OS version with latest SP
 Use the newest SQL Server version with latest SP
 Use the 64-bit version of the OS and SQL Server
 When upgrading, it is always safer to upgrade to
a new server with a fresh installation of the OS
and SQL Server than to upgrade in place.This
allows you to test more effectively, and also
gives you a backout option.
 Is the OS configured to optimize background
applications?
 Need to have at least 20% free disk space on all
disk drives. Important for NTFS performance.
 SQL Server instance should be a stand-alone
server with no other apps running on it.
 Unnecessary services should be turned off.
 Don’t run antivirus software locally.
 Ideally, use 64-bit hardware and the 64-bit
version of SQL Server.
 If using 32-bit version, and if using 4 GB or more
of RAM, ensure than AWE memory is correctly
configured.
 Remove physical file fragmentation before
adding new MDF or LDF files
 The OS and SQL Server binaries should be on
their own volume
 MDF files should be located on their own volume
 LDF files should be located on their own volume
 Pre-size MDFs and LDFs to minimize autogrowth
 Use Instant File Initialization
 Locate on its own volume
 Keep recovery model to SIMPLE
 Pre-size so autogrowth doesn’t have to happen
 Set autogrowth to avoid many growth spurts,
use fixed amount.
 Divide the tempdb into multiple files, so that the
number of files is about 50% to 100% of the
number of CPU cores your server has. Each file
should be the same size.
 Auto Create Statistics: On
 Auto Update Statistics: On
 Auto Shrink: Off
 PageVerify: Checksum (2005/2008)
 Autogrowth: Use mainly for catching mistakes.
File growth should be managed manually. Use
fixed amount, not percentage growth.
 Production databases should be set to FULL
RECOVERY.
 Schedule jobs so they don’t interfere with
production.
 Ensure that jobs don’t overlap.
 Don’t ever schedule automatic shrinking of
databases. If you must shrink a file, do it manually
and off hours, then rebuild indexes.
 Don’t schedule an UPDATE STATISTICS job before or
after an INDEX REBUILD/REORGANIZE job. It is
redundant, and can actually reduce the quality of the
statistics (if run after).
 Rebuild an index if it is heavily fragmented (>30%). In Enterprise
Edition, can perform online. If Standard Edition, can cause
blocking, and should ideally be done during slow/down times.
 Reorganize an index if it is not heavily fragmented (>5% and <=
30%).This is an online operation and doesn’t use a lot of resources.
 Use a fill factor large enough to prevent page splitting, but small
enough to prevent wasted space on disk and in memory. Use 100
for read-only tables, try 95 as a starting point for OLTP tables.
 Ideally, you should only rebuild or reorganize indexes that need
rebuilding, especially for very large databases. Use
sys.dm_db_index_physical_stats to identify fragmentation.
 If databases are small, or you don’t know how to identify which
indexes are fragmented, then consider running a nightly or weekly
job to rebuild or reorganize indexes in all of your user databases.
 Run DBCCCHECKDB as often as you run full backups, which is
probably daily.
 Create an appropriate job to run this command:
DBCC CHECKDB (‘DATABASE_NAME') WITH
NO_INFOMSGS, ALL_ERRORMSGS;
Note: Use PHYSICAL_ONLY option for large or busy
production servers.
 Review results to look for problems. If you have a problem, you
want to find it as soon as possible to reduce the risk of data loss.
A restore is often the only way to fix many data corruption
problems.
 Create a SQL Server Event Alert for all events
with a severity of 11 and higher (or at least 19
[fatal] and higher).
 Have alert sent to e-mail address, or to your
texting e-mail address.
 Don’t use the SA account for anything.
 UseWindows Authentication security whenever
possible.
 Don’t give users more permissions than they
need to perform their job.
 Only log onto a SQL Server as a sysadmin if you
need to perform sysadmin tasks, otherwise use a
different account to log onto SQL Server.
 Log off your SQL Server when done.
 Create a job to perform full backups daily on all
system and user production databases, plus log
backups hourly (or similar variation).
 Always backup using RESTORE WITHVERIFYONLY
to help verify backup integrity.
 Keep full backup for at least several days, 7 or more
days is ideal.
 Store backups securely and off-site.
 If you have a limited backup window, or have limited
disk space, consider a third-party backup program
that does compression. Can be a big time saver.
 You must create a document that outlines, step-
by-step, in great detail, how you will recover your
SQL Servers in the case of any problem, small or
large.
 You need to practice using the plan so you are
familiar with it and can implement it without
requiring any further research.
 Keep Microsoft SQL Server’s Product Support
phone number handily available.
 Before you make any change in a production SQL
Server, be sure you test it first in a test
environment.
 NO EXCEPTIONS! I mean it! Really!
 Monitor MDF and LDF file growth
 Monitor Free Space
 Monitor SQL Server and OS Logs
 Monitor Jobs
 Monitor Alerts
 Test Backups
 Monitor Performance
 Analyze Indexes
 Document All Changes
 MDF and LDF files should be managed manually.
 To do this well, you must monitor file growth and
be aware of how much data is being added.
 Be proactive. Plan early to add more space if
needed, don’t wait until it’s too late.
 In SQL Server 2005, use “Standard Reports” to
help you monitor this.
 In SQL Server 2008, use Performance Data
Collector to monitor this.
 No disk should ever exceed 80% capacity.When
it does, performance drops, and you risk running
out of disk space.
 Check this manually and record results
 Use Performance Monitor and setup an alert
 Use a third-party tool
 Write your own tool
 Daily, review SQL Server Event Logs
 Application
 System
 Security
 Daily, review SQL Server Logs
 How to perform:
 Manual check using EventViewer or SSMS
 Have “Errors” e-mailed to you from EventViewer
 Use third-party tool
 Write your own tool
 Daily, verify that all jobs have run successfully.
 Keep in mind that sometimes, a job may claim to
be successful, but it failed in part or whole.
 How to perform:
 Manually check
 Have SQL ServerAgent send you a message
 Use third-party tool
 Write your own tool
 If you do set up any of the many available alerts,
be sure you look at them.
 Sometimes, it is easy to be complacent and to
ignore alerts.
 The secret is to keep alerts to a minimum by
carefully creating the alerts, setting them up so
that only the most critical alerts are sent.
 At the very minimum, perform a test restore on
at least one key production database, per SQL
Server instance, weekly.
 The restore is best done on a test server, but if
not available, restore on production server using
different name. When restore is done, then
remove.
 Monitor performance regularly, daily if
necessary.
 Identify potential problems early before they
become critical problems.
 How to monitor:
 Performance Monitor
 Profiler
 SQL Server 2005 Performance Dashboard
 SQL Server 2008 Performance Data Collector
 Third-PartyTools
 Indexing needs of a database can change over time
as data changes, and as how data is queried
changes.
 Every 1-3 months, perform a default Profiler trace on
your production servers, then use the trace as the
source for the Database EngineTuning Advisor to
help you identify missing indexes.
 Remove unused indexes. Identify by using the
sys.dm_db_index_usage_stats DMV
 Using correct indexes is one of the key ways to get
better SQL Server performance.
 Whether you are the only DBA, or one of many,
all SQL Server changes needs to be documented.
 Acts as an audit trail (often required by many
organizations).
 Documentation helps you to troubleshoot
problems, and also acts as a repository of
information for future use.
 Ideally, put documentation where is can be easily
accessed by all interested parties.
 By focusing on the basics, you gain the following:
 Better SQL Server performance
 Higher SQL Server availability
 Being proactive helps to you prevent being in a “crisis”
mode all the time
 More time to focus on what is important to you
 You become a better, more professional DBA
 The total effect of following each and every
recommendation made today can be huge.
 Time for your questions
 CheckThese Out:
 www.SQLServerCentral.com
 www.Simple-Talk.com
 www.ExceptionalDBA.com
 www.SQL-Server-Performance.com
 Contact me at:
 bradmcgehee@hotmail.com

Contenu connexe

Tendances

Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Aaron Shilo
 
Sql Server Performance Tuning
Sql Server Performance TuningSql Server Performance Tuning
Sql Server Performance TuningBala Subra
 
MYSQL_Basic_Performance_Tuning_Guidelines_-_V2
MYSQL_Basic_Performance_Tuning_Guidelines_-_V2MYSQL_Basic_Performance_Tuning_Guidelines_-_V2
MYSQL_Basic_Performance_Tuning_Guidelines_-_V2Shelton Reese
 
Performance Tuning
Performance TuningPerformance Tuning
Performance TuningJannet Peetz
 
OOUG - Oracle Performance Tuning with AAS
OOUG - Oracle Performance Tuning with AASOOUG - Oracle Performance Tuning with AAS
OOUG - Oracle Performance Tuning with AASKyle Hailey
 
SQL Server and System Center Advisor
SQL Server and System Center AdvisorSQL Server and System Center Advisor
SQL Server and System Center AdvisorEduardo Castro
 
SQL Server Tuning to Improve Database Performance
SQL Server Tuning to Improve Database PerformanceSQL Server Tuning to Improve Database Performance
SQL Server Tuning to Improve Database PerformanceMark Ginnebaugh
 
Oracle DB Performance Tuning Tips
Oracle DB Performance Tuning TipsOracle DB Performance Tuning Tips
Oracle DB Performance Tuning TipsAsanka Dilruk
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuningngupt28
 
SQL Server Query Tuning Tips - Get it Right the First Time
SQL Server Query Tuning Tips - Get it Right the First TimeSQL Server Query Tuning Tips - Get it Right the First Time
SQL Server Query Tuning Tips - Get it Right the First TimeDean Richards
 
Oracle database performance tuning
Oracle database performance tuningOracle database performance tuning
Oracle database performance tuningAbishek V S
 
Geek Sync I SQL Server Tuning without Touching T-SQL
Geek Sync I SQL Server Tuning without Touching T-SQLGeek Sync I SQL Server Tuning without Touching T-SQL
Geek Sync I SQL Server Tuning without Touching T-SQLIDERA Software
 
Exploring Scalability, Performance And Deployment
Exploring Scalability, Performance And DeploymentExploring Scalability, Performance And Deployment
Exploring Scalability, Performance And Deploymentrsnarayanan
 
Oracle db performance tuning
Oracle db performance tuningOracle db performance tuning
Oracle db performance tuningSimon Huang
 
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 KnowDean Richards
 
End-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL ServerEnd-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL ServerKevin Kline
 

Tendances (16)

Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
 
Sql Server Performance Tuning
Sql Server Performance TuningSql Server Performance Tuning
Sql Server Performance Tuning
 
MYSQL_Basic_Performance_Tuning_Guidelines_-_V2
MYSQL_Basic_Performance_Tuning_Guidelines_-_V2MYSQL_Basic_Performance_Tuning_Guidelines_-_V2
MYSQL_Basic_Performance_Tuning_Guidelines_-_V2
 
Performance Tuning
Performance TuningPerformance Tuning
Performance Tuning
 
OOUG - Oracle Performance Tuning with AAS
OOUG - Oracle Performance Tuning with AASOOUG - Oracle Performance Tuning with AAS
OOUG - Oracle Performance Tuning with AAS
 
SQL Server and System Center Advisor
SQL Server and System Center AdvisorSQL Server and System Center Advisor
SQL Server and System Center Advisor
 
SQL Server Tuning to Improve Database Performance
SQL Server Tuning to Improve Database PerformanceSQL Server Tuning to Improve Database Performance
SQL Server Tuning to Improve Database Performance
 
Oracle DB Performance Tuning Tips
Oracle DB Performance Tuning TipsOracle DB Performance Tuning Tips
Oracle DB Performance Tuning Tips
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuning
 
SQL Server Query Tuning Tips - Get it Right the First Time
SQL Server Query Tuning Tips - Get it Right the First TimeSQL Server Query Tuning Tips - Get it Right the First Time
SQL Server Query Tuning Tips - Get it Right the First Time
 
Oracle database performance tuning
Oracle database performance tuningOracle database performance tuning
Oracle database performance tuning
 
Geek Sync I SQL Server Tuning without Touching T-SQL
Geek Sync I SQL Server Tuning without Touching T-SQLGeek Sync I SQL Server Tuning without Touching T-SQL
Geek Sync I SQL Server Tuning without Touching T-SQL
 
Exploring Scalability, Performance And Deployment
Exploring Scalability, Performance And DeploymentExploring Scalability, Performance And Deployment
Exploring Scalability, Performance And Deployment
 
Oracle db performance tuning
Oracle db performance tuningOracle db performance tuning
Oracle db performance tuning
 
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
 
End-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL ServerEnd-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL Server
 

Similaire à SQL Server DBA Best Practices

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 2014Antonios Chatzipavlis
 
PASS Spanish Recomendaciones para entornos de SQL Server productivos
PASS Spanish   Recomendaciones para entornos de SQL Server productivosPASS Spanish   Recomendaciones para entornos de SQL Server productivos
PASS Spanish Recomendaciones para entornos de SQL Server productivosJavier Villegas
 
Managing SQLserver for the reluctant DBA
Managing SQLserver for the reluctant DBAManaging SQLserver for the reluctant DBA
Managing SQLserver for the reluctant DBAConcentrated Technology
 
DBA, LEVEL III TTLM Monitoring and Administering Database.docx
DBA, LEVEL III TTLM Monitoring and Administering Database.docxDBA, LEVEL III TTLM Monitoring and Administering Database.docx
DBA, LEVEL III TTLM Monitoring and Administering Database.docxseifusisay06
 
KoprowskiT_SQLSaturday409_MaintenancePlansForBeginners
KoprowskiT_SQLSaturday409_MaintenancePlansForBeginnersKoprowskiT_SQLSaturday409_MaintenancePlansForBeginners
KoprowskiT_SQLSaturday409_MaintenancePlansForBeginnersTobias Koprowski
 
KoprowskiT_SQLSat409_MaintenancePlansForBeginners
KoprowskiT_SQLSat409_MaintenancePlansForBeginnersKoprowskiT_SQLSat409_MaintenancePlansForBeginners
KoprowskiT_SQLSat409_MaintenancePlansForBeginnersTobias Koprowski
 
Database Maintenance Optimization Brad Mc Gehee
Database Maintenance Optimization   Brad Mc GeheeDatabase Maintenance Optimization   Brad Mc Gehee
Database Maintenance Optimization Brad Mc GeheePratik joshi
 
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent Ozar
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent OzarGeek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent Ozar
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent OzarIDERA Software
 
How Not to be a Cranky DBA
How Not to be a Cranky DBAHow Not to be a Cranky DBA
How Not to be a Cranky DBAMike Hillwig
 
Best Practices and Lessons Learned on Our IBM Rational Insight Deployment
Best Practices and Lessons Learned on Our IBM Rational Insight DeploymentBest Practices and Lessons Learned on Our IBM Rational Insight Deployment
Best Practices and Lessons Learned on Our IBM Rational Insight DeploymentMarc Nehme
 
SQL Server Reporting Services (SSRS) 101
 SQL Server Reporting Services (SSRS) 101 SQL Server Reporting Services (SSRS) 101
SQL Server Reporting Services (SSRS) 101Sparkhound Inc.
 
Do More With Less: SQL Central Management Server and Multi-Server Administration
Do More With Less: SQL Central Management Server and Multi-Server AdministrationDo More With Less: SQL Central Management Server and Multi-Server Administration
Do More With Less: SQL Central Management Server and Multi-Server AdministrationMike Hillwig
 
How not to be a cranky dba
How not to be a cranky dbaHow not to be a cranky dba
How not to be a cranky dbaMike Hillwig
 
Managing RightScale on RightScale
Managing RightScale on RightScaleManaging RightScale on RightScale
Managing RightScale on RightScaleRightScale
 
Best practice adoption (and lack there of)
Best practice adoption (and lack there of)Best practice adoption (and lack there of)
Best practice adoption (and lack there of)John Pape
 
Database operations
Database operationsDatabase operations
Database operationsRobert Crane
 
Continuent Tungsten - Scalable Saa S Data Management
Continuent Tungsten - Scalable Saa S Data ManagementContinuent Tungsten - Scalable Saa S Data Management
Continuent Tungsten - Scalable Saa S Data Managementguest2e11e8
 

Similaire à SQL Server DBA Best Practices (20)

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
 
PASS Spanish Recomendaciones para entornos de SQL Server productivos
PASS Spanish   Recomendaciones para entornos de SQL Server productivosPASS Spanish   Recomendaciones para entornos de SQL Server productivos
PASS Spanish Recomendaciones para entornos de SQL Server productivos
 
Managing SQLserver for the reluctant DBA
Managing SQLserver for the reluctant DBAManaging SQLserver for the reluctant DBA
Managing SQLserver for the reluctant DBA
 
DBA, LEVEL III TTLM Monitoring and Administering Database.docx
DBA, LEVEL III TTLM Monitoring and Administering Database.docxDBA, LEVEL III TTLM Monitoring and Administering Database.docx
DBA, LEVEL III TTLM Monitoring and Administering Database.docx
 
KoprowskiT_SQLSaturday409_MaintenancePlansForBeginners
KoprowskiT_SQLSaturday409_MaintenancePlansForBeginnersKoprowskiT_SQLSaturday409_MaintenancePlansForBeginners
KoprowskiT_SQLSaturday409_MaintenancePlansForBeginners
 
KoprowskiT_SQLSat409_MaintenancePlansForBeginners
KoprowskiT_SQLSat409_MaintenancePlansForBeginnersKoprowskiT_SQLSat409_MaintenancePlansForBeginners
KoprowskiT_SQLSat409_MaintenancePlansForBeginners
 
Database Maintenance Optimization Brad Mc Gehee
Database Maintenance Optimization   Brad Mc GeheeDatabase Maintenance Optimization   Brad Mc Gehee
Database Maintenance Optimization Brad Mc Gehee
 
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent Ozar
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent OzarGeek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent Ozar
Geek Sync | Planning a SQL Server to Azure Migration in 2021 - Brent Ozar
 
How Not to be a Cranky DBA
How Not to be a Cranky DBAHow Not to be a Cranky DBA
How Not to be a Cranky DBA
 
Best Practices and Lessons Learned on Our IBM Rational Insight Deployment
Best Practices and Lessons Learned on Our IBM Rational Insight DeploymentBest Practices and Lessons Learned on Our IBM Rational Insight Deployment
Best Practices and Lessons Learned on Our IBM Rational Insight Deployment
 
Managing SQLserver
Managing SQLserverManaging SQLserver
Managing SQLserver
 
SQL Server Reporting Services (SSRS) 101
 SQL Server Reporting Services (SSRS) 101 SQL Server Reporting Services (SSRS) 101
SQL Server Reporting Services (SSRS) 101
 
Do More With Less: SQL Central Management Server and Multi-Server Administration
Do More With Less: SQL Central Management Server and Multi-Server AdministrationDo More With Less: SQL Central Management Server and Multi-Server Administration
Do More With Less: SQL Central Management Server and Multi-Server Administration
 
How not to be a cranky dba
How not to be a cranky dbaHow not to be a cranky dba
How not to be a cranky dba
 
Managing RightScale on RightScale
Managing RightScale on RightScaleManaging RightScale on RightScale
Managing RightScale on RightScale
 
Best practice adoption (and lack there of)
Best practice adoption (and lack there of)Best practice adoption (and lack there of)
Best practice adoption (and lack there of)
 
Database operations
Database operationsDatabase operations
Database operations
 
SharePoint Performance
SharePoint PerformanceSharePoint Performance
SharePoint Performance
 
Patrick_Rebrook_Resume
Patrick_Rebrook_ResumePatrick_Rebrook_Resume
Patrick_Rebrook_Resume
 
Continuent Tungsten - Scalable Saa S Data Management
Continuent Tungsten - Scalable Saa S Data ManagementContinuent Tungsten - Scalable Saa S Data Management
Continuent Tungsten - Scalable Saa S Data Management
 

Dernier

A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...itnewsafrica
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfAarwolf Industries LLC
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 

Dernier (20)

A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdf
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 

SQL Server DBA Best Practices

  • 1. Brad M. McGehee SQL Server MVP Director of DBA Education Red Gate Software
  • 2.  You may be a part-time or full-time DBA  You may be a DBA Administrator or DBA Developer  You may have less than one year’s experience as a SQL Server DBA  You may be an experienced DBA, but don’t mind spending a little time reviewing DBA fundamentals, because you may learn something new, or remind you of something you forgot.
  • 3.  Helps to optimize SQL Server performance  Helps to maximum SQL Server availability  Helps you to be proactive, not reactive  Helps you to reduce being in “crisis” mode  Reduces your stress levels  Makes your manager happier  Give you more time to focus on what really interests you
  • 4.  While each best practice I discuss today might seem small, the total effect of following each and every recommendation can be huge.  By closely following each of these best practices, SQL Server performance and availability can be boosted by 20%, 50%, or even more.
  • 5.  Check &Verify  One-time checks to verify proper SQL Server instance configuration  On-GoingTasks  Daily, weekly, monthly tasks that need on-going attention 1. Our focus today is on what to do, not how to do it. 2. Best practices are based on the biggest mistakes I see DBAs make. 3. These best practices are just the basics, there are a lot more to learn. 4. There are always exceptions to every rule, and not every recommendation discussed here may fit your environment.
  • 6.  Installing & Upgrading SQL Server  General Configuration  Memory Configuration  User Data and Log File Management  Tempdb Management  Database Configuration Settings  Configuring Jobs—General  Create Index Rebuilding/Reorganize Job  Create Data Corruption Detection Job  Set Up Alerts for Critical Errors  Security Basics  Implement a Backup Strategy  Create a Disaster Recovery Plan  Test Everything
  • 7.  When installing a new SQL Server instance:  Use the newest OS version with latest SP  Use the newest SQL Server version with latest SP  Use the 64-bit version of the OS and SQL Server  When upgrading, it is always safer to upgrade to a new server with a fresh installation of the OS and SQL Server than to upgrade in place.This allows you to test more effectively, and also gives you a backout option.
  • 8.  Is the OS configured to optimize background applications?  Need to have at least 20% free disk space on all disk drives. Important for NTFS performance.  SQL Server instance should be a stand-alone server with no other apps running on it.  Unnecessary services should be turned off.  Don’t run antivirus software locally.
  • 9.  Ideally, use 64-bit hardware and the 64-bit version of SQL Server.  If using 32-bit version, and if using 4 GB or more of RAM, ensure than AWE memory is correctly configured.
  • 10.  Remove physical file fragmentation before adding new MDF or LDF files  The OS and SQL Server binaries should be on their own volume  MDF files should be located on their own volume  LDF files should be located on their own volume  Pre-size MDFs and LDFs to minimize autogrowth  Use Instant File Initialization
  • 11.  Locate on its own volume  Keep recovery model to SIMPLE  Pre-size so autogrowth doesn’t have to happen  Set autogrowth to avoid many growth spurts, use fixed amount.  Divide the tempdb into multiple files, so that the number of files is about 50% to 100% of the number of CPU cores your server has. Each file should be the same size.
  • 12.  Auto Create Statistics: On  Auto Update Statistics: On  Auto Shrink: Off  PageVerify: Checksum (2005/2008)  Autogrowth: Use mainly for catching mistakes. File growth should be managed manually. Use fixed amount, not percentage growth.  Production databases should be set to FULL RECOVERY.
  • 13.  Schedule jobs so they don’t interfere with production.  Ensure that jobs don’t overlap.  Don’t ever schedule automatic shrinking of databases. If you must shrink a file, do it manually and off hours, then rebuild indexes.  Don’t schedule an UPDATE STATISTICS job before or after an INDEX REBUILD/REORGANIZE job. It is redundant, and can actually reduce the quality of the statistics (if run after).
  • 14.  Rebuild an index if it is heavily fragmented (>30%). In Enterprise Edition, can perform online. If Standard Edition, can cause blocking, and should ideally be done during slow/down times.  Reorganize an index if it is not heavily fragmented (>5% and <= 30%).This is an online operation and doesn’t use a lot of resources.  Use a fill factor large enough to prevent page splitting, but small enough to prevent wasted space on disk and in memory. Use 100 for read-only tables, try 95 as a starting point for OLTP tables.  Ideally, you should only rebuild or reorganize indexes that need rebuilding, especially for very large databases. Use sys.dm_db_index_physical_stats to identify fragmentation.  If databases are small, or you don’t know how to identify which indexes are fragmented, then consider running a nightly or weekly job to rebuild or reorganize indexes in all of your user databases.
  • 15.  Run DBCCCHECKDB as often as you run full backups, which is probably daily.  Create an appropriate job to run this command: DBCC CHECKDB (‘DATABASE_NAME') WITH NO_INFOMSGS, ALL_ERRORMSGS; Note: Use PHYSICAL_ONLY option for large or busy production servers.  Review results to look for problems. If you have a problem, you want to find it as soon as possible to reduce the risk of data loss. A restore is often the only way to fix many data corruption problems.
  • 16.  Create a SQL Server Event Alert for all events with a severity of 11 and higher (or at least 19 [fatal] and higher).  Have alert sent to e-mail address, or to your texting e-mail address.
  • 17.  Don’t use the SA account for anything.  UseWindows Authentication security whenever possible.  Don’t give users more permissions than they need to perform their job.  Only log onto a SQL Server as a sysadmin if you need to perform sysadmin tasks, otherwise use a different account to log onto SQL Server.  Log off your SQL Server when done.
  • 18.  Create a job to perform full backups daily on all system and user production databases, plus log backups hourly (or similar variation).  Always backup using RESTORE WITHVERIFYONLY to help verify backup integrity.  Keep full backup for at least several days, 7 or more days is ideal.  Store backups securely and off-site.  If you have a limited backup window, or have limited disk space, consider a third-party backup program that does compression. Can be a big time saver.
  • 19.  You must create a document that outlines, step- by-step, in great detail, how you will recover your SQL Servers in the case of any problem, small or large.  You need to practice using the plan so you are familiar with it and can implement it without requiring any further research.  Keep Microsoft SQL Server’s Product Support phone number handily available.
  • 20.  Before you make any change in a production SQL Server, be sure you test it first in a test environment.  NO EXCEPTIONS! I mean it! Really!
  • 21.  Monitor MDF and LDF file growth  Monitor Free Space  Monitor SQL Server and OS Logs  Monitor Jobs  Monitor Alerts  Test Backups  Monitor Performance  Analyze Indexes  Document All Changes
  • 22.  MDF and LDF files should be managed manually.  To do this well, you must monitor file growth and be aware of how much data is being added.  Be proactive. Plan early to add more space if needed, don’t wait until it’s too late.  In SQL Server 2005, use “Standard Reports” to help you monitor this.  In SQL Server 2008, use Performance Data Collector to monitor this.
  • 23.  No disk should ever exceed 80% capacity.When it does, performance drops, and you risk running out of disk space.  Check this manually and record results  Use Performance Monitor and setup an alert  Use a third-party tool  Write your own tool
  • 24.  Daily, review SQL Server Event Logs  Application  System  Security  Daily, review SQL Server Logs  How to perform:  Manual check using EventViewer or SSMS  Have “Errors” e-mailed to you from EventViewer  Use third-party tool  Write your own tool
  • 25.  Daily, verify that all jobs have run successfully.  Keep in mind that sometimes, a job may claim to be successful, but it failed in part or whole.  How to perform:  Manually check  Have SQL ServerAgent send you a message  Use third-party tool  Write your own tool
  • 26.  If you do set up any of the many available alerts, be sure you look at them.  Sometimes, it is easy to be complacent and to ignore alerts.  The secret is to keep alerts to a minimum by carefully creating the alerts, setting them up so that only the most critical alerts are sent.
  • 27.  At the very minimum, perform a test restore on at least one key production database, per SQL Server instance, weekly.  The restore is best done on a test server, but if not available, restore on production server using different name. When restore is done, then remove.
  • 28.  Monitor performance regularly, daily if necessary.  Identify potential problems early before they become critical problems.  How to monitor:  Performance Monitor  Profiler  SQL Server 2005 Performance Dashboard  SQL Server 2008 Performance Data Collector  Third-PartyTools
  • 29.  Indexing needs of a database can change over time as data changes, and as how data is queried changes.  Every 1-3 months, perform a default Profiler trace on your production servers, then use the trace as the source for the Database EngineTuning Advisor to help you identify missing indexes.  Remove unused indexes. Identify by using the sys.dm_db_index_usage_stats DMV  Using correct indexes is one of the key ways to get better SQL Server performance.
  • 30.  Whether you are the only DBA, or one of many, all SQL Server changes needs to be documented.  Acts as an audit trail (often required by many organizations).  Documentation helps you to troubleshoot problems, and also acts as a repository of information for future use.  Ideally, put documentation where is can be easily accessed by all interested parties.
  • 31.  By focusing on the basics, you gain the following:  Better SQL Server performance  Higher SQL Server availability  Being proactive helps to you prevent being in a “crisis” mode all the time  More time to focus on what is important to you  You become a better, more professional DBA  The total effect of following each and every recommendation made today can be huge.
  • 32.  Time for your questions
  • 33.  CheckThese Out:  www.SQLServerCentral.com  www.Simple-Talk.com  www.ExceptionalDBA.com  www.SQL-Server-Performance.com  Contact me at:  bradmcgehee@hotmail.com