Maintenance Plans for Beginners (but not only) | Each of experienced administrators used (to some extent) what is called Maintenance Plans - Plans of Conservation. During this session, I'd like to discuss what can be useful for us to provide functionality when we use them and what to look out for. Session at 200 times the forward-300, with the opening of the discussion.
4. ABOUT ME
Memberof the Boards:
PolishInformation Processing Society
Global IT CommunityAssociation
PolishSQL Server User GroupLeader
Microsoft CertifiedTrainer(MCP, MCSA, MLSS, MLSBS, MCTS, MCITP)
SQL Server MVP (five yearsin a row)
MVP Mentor Program Member
Blogger, Influencer, Technical Writer
Last9 yearsspendin Data Center in Wrocław
About15 years in IT/banking area
Speaker at SQL Server Community Launch, Time for SharePoint, CodeCamps, SharePoint Community Launch, CISSP Day, SQL in the City, InfoTRAMS, SQL Bits, SQL Saturday, CareerCon, Sharepoint& SQL Connection, IT Camp, SQL Rally, SQL Relay…
DeepDivesCo-Author:
High availability of SQL Server in the context of SLA (Chapter18th)
Technical reviewer:
ExploringMDX for SQL Server 2012
@KoprowskiT
5. AGENDA
MaintenancePlans –what are you talking about?
MaintenancePlans –how, where, when?
Methods, tools, right (?) ways
What Maintenance Plans can do you You
BackUpDatabase
VerifyIntegrityof Database
Maintaina Database Indexes
MaintainIndex & ColumnStatistics
RemoveOlderData from msdb
RemoveOldBackups
MaintenancePlans–howcontrolchanges?
Examples
Q&A
#SQLSatKharkov 5
7. Maintenance Plans –what are you talking about?
Clean Environment
Silence
Knowledge about environment
Productivity / Performance
DEFINITION:
A database maintenance plan is a set of specific, proactive task that need to be performer regularly on databases to ensure their adequate performance and availability
#SQLSatKharkov
7
9. Maintenance Plans –how, where, when?
HOW:
MaintenancePlan Wizard
MaintenancePlan Designer
T-SQL Scripts
PowerShellScripts
WHERE
SQL Server Management Studio from Standard and above
See you in… Express
WHEN:
BEFORE: problems / service windows
AFTER: maintaining / clients back to home
#SQLSatKharkov
9
10. HOW: Maintenance Plan Wizard
Very simple (although advanced) wizard
Providing possibility for creation simple task in dozens of seconds
Enough in many cases, environments
Limited but huge number of options
Limitations:
number of databases
granularity
single tasks / no multitasking
no scripting for another instances
some known problems in previous version of SQL Server
SQL Server 2005 Service Pack 2
SQL Server 2008
#SQLSatKharkov
10
11. HOW: Maintenance Plan Designer
More flexible and advanced tool (not on this session)
Graphical user interface with SSIS
Most often used for „really DBA”
Increased features
Workflow for specified tasks with execution plan
Multitasking
Two additional Maintenance plans
ExecuteT-SQL Statement
Notify Operator
#SQLSatKharkov
11
12. LIMITATIONS: Maintenance Plan wizard & Designer
Limitations for both tools / those ideas are not possible
Identification and removing fragmentation for physical files
Identification abandoned, duplicated, forgotten indexes
Providing backup on demand
Werification good quality of backup
Werification succesful restore
Monitoring of performance
Monitoring of SQL OS
Monitoring of Windows OS
Monitoring available space
#SQLSatKharkov
12
13. Maintenance Plan: t-sql & powershell scripts
Functionality for „Real *Tru* DBA”
Necessary for working with multiple databases, instances, server farms
Feauters for scripting:
Access to OS
Posibility of moving
Scripts sharing
One of the best examples and tools for free:
HTTP://OLA.HALLENGREN.COM/
#SQLSatKharkov
13
15. Maintenance plans: available tasks
CheckDatabase Integrity
DBCC CHECKDB
ShrinkDatabase
NEVER, NEVER, NEVER
ReorganizeIndex
ALTER INDEX , and next Update Statistics
RebuildIndex
ALTER INDEX, Update Statistics are not necessary
Update Statistics
Sp_updatestats
HistoryCleanup
Using msdb, don’t do that too much frequently
#SQLSatKharkov
15
16. Maintenance plans: available tasks
ExecuteSQL Server Agent Job
Providing scrip using wen You work with agent
BackUpDatabase (Full)
Executing BACKUP DATABASE with FULLoption, and next Transaction Log
BackUpDatabase (Differential)
Executing BACKUP DATABASE with DIFFERENTIAL option
BackUpDatabase (TransactionLog)
Executing BACKUP LOG, frequency...
MaintenanceCleanupTask
Most complicated feature ? BAK, TRN, TXT
#SQLSatKharkov
16
17. Functionality: Verify Integrity of Database
YOU SHOULD REMEMBER
usingDBCC CHECKDB
Daily
Weekly
Monthly
DBCCCHECKDB(’database_name’)WITHNO_INFOMSGS
Suppressesallinformationalmessages.
DBCCCHECKDB(’database_name’)WITHNO_INFOMSGS,ALL_ERRORMSGS
Displaysallreportederrorsperobject.Allerrormessagesaredisplayedbydefault.Specifyingoromittingthisoptionhasnoeffect.ErrormessagesaresortedbyobjectID,exceptforthosemessagesgeneratedfromtempdbdatabase.
InSQLServerManagementStudio,themaximumnumberoferrormessagesreturnedis1000.
DBCCCHECKDB(’database_name’)NOINDEX
Specifiesthatintensivechecksofnonclusteredindexesforusertablesshouldnotbeperformed. Thisdecreasestheoverallexecutiontime.NOINDEXdoesnotaffectsystemtablesbecauseintegritychecksarealwaysperformedonsystemtableindexes
#SQLSatKharkov
17
18. POSSIBILITIES: SHRINK DATABASE
YOU SHOULD REMEMBER
NEVER USE THIS OPTION IN MAINTENACE PLANS
MDF & LDF
100 GB reserved
15 GB in use
DBCC SHRINKDATABASE
or
DBCC SHRINKFILE | MANUAL MODE
Reduction of Reserved Space
#SQLSatKharkov
18
19. POSSIBILITIES: Maintain Index & Column Statistics
YOU SHOULD REMEMBER
Automation:
AUTO_CREATE_STATISTICS
AUTO_UPDATE_STATISTICS
Executing automatically after: INSERT, UPDATE, DELETE
UPDATE STATISTICS table_name WITH FULLSCAN
When:
Never…
Just after Index Reorganization
On the days when we’re not using Index Rebuild or Reorganize Index
Important options (UPDATE STATISTICS):
Allexistingstatistics
Columnstatisticsonly
Index statisticsonly
#SQLSatKharkov
19
21. POSSIBILITIES: history clean up (MSDB)
YOU MUST REMEMBER
Choosingthe data (right data) for deleting:
Backup and restorehistory
SQL Server Agent jobhistory
MaintenancePlan history
#SQLSatKharkov
21
23. Link database to SVN, TFS, Git, Mercurial, Vault, Perforce
Source control for schemas and data
Push and pull database changes in SSMS
Check development history and access specific database versions
Store and share scripts to handle complex changes, such as column splits
Undo SQL Server changes
Exclude objects from source control using custom filters.
Supports SQL Server on Amazon RDS
View SQL differences between objects in a database and source control
Work with SQL Compare and SQL Data Compare to deploy databases directly from source controlhttp://www.red-gate.com/products/sql-development/sql-source-control/
Maintenanceplans: howcontolit?
28. We should remember about:
Task sequences
Task execution
Task priority
Documentation
Using: daily / weekly / occasionally
Better expoloration of our environment
Monitoring (partially) of performance
Standard and above (sorry)
MaintenancePlan Wizard
for beginners and small installations
Maintenance Plan Designer
Adult, more complicated, wideenvironment
MaintenancePlansControl with RedGateSource Control
Scripts control
Database changes
SUMMARY
#SQLSatKharkov
28
29. BradMcGehee| Brad’ Sure Guide to SQL Server Maintenance Plans
„My new eBook,Brad’ Sure Guide to SQL Server Maintenance Plansis now available as
a free, 269 page PDF eBook. The book is designed for part-time or novice DBAs who
want to learn how to properly create Maintenance Plans using the tools that come with
SQL Server Management Studio (SSMS) in SQL Server 2005/2008.
LINK: http://bit.ly/1ijdnah
Ola Hallengreen| MaintenancePlansScripts PASS slidedeck
„The SQL Server Maintenance Solution comprises scripts for running backups,
integrity checks, and index and statistics maintenance on all editions of Microsoft
SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012. The
solution is based on stored procedures, sqlcmdutility, and SQL Server Agent jobs”
LINK: http://bit.ly/1b220Ns
LINKS
#SQLSatKharkov
29
30. White Papers:
http://www.red-gate.com/products/sql-development/sql-source- control/learn-more/white-papers
Case Study video of SQL Source Control & Continuous integration:
http://play.buto.tv/yhkvl
Product Manager& Developer session on Top tops for Continuous Integration:
http://play.buto.tv/TzmXD
LINKS
#SQLSatKharkov
30