Premier 
Gold 
Silver 
Bronze 
Our awesome sponsors
MaintenancePlansfor beginners 
@KoprowskiT
MaintenancePlansfor beginners 
@KoprowskiT
ABOUT ME 
•Leader of Polish SQL Server User Group 
•Microsoft CertifiedTrainer(SharePoint, SQL Server, Security, Azure) 
•SQL Server MVP (five years) 
•MVP Mentor Program Member 
•consultant, security& licensingauditor 
•activeblogger, influencer, technicalwriter 
•last9 yearslivingin Data Processing Center 
•last14 yearsbanking and ICT 
•NOW goingintoIndependent Consultancy 
•frequentlyspeaker atseveralconferences: SQL Server Community Launch, Time for SharePoint, CodeCamps, InfoMEET, SharePoint Community Launch, CISSP Day, SQL in the City, InfoTRAMS, SQL Bits, IT Camp, SQL Saturday, CareerCon, Sharepoint& SQL Connection, Kariera IT, SQL Rally, SQL Relay, InfoTech… 
•Microsoft TerminologyCommunity/ translationsfor Wndows7/8 and Visual Studio 2010/2012 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 4
AGENDA 
PHASE ONE –slidetalks 
•MP–whatwe aretalkingabout? 
•MP –how, where, when? 
•MP -methods, tools, right (?) ways 
•whatMaintenance Plans can do you You 
PHASE TWO –show time 
PHASE THREE –discussiontime 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 5
PHASE ONE –slidetalks
MaintenancePlans–whatwe aretalkingabout? 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners
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, proactivetask 
thatneed to be performedregularlyon databases 
to ensuretheiradequate performance and availability 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 8
Maintenance Plans –what are you talking about? 
•To create or manage maintenance plans you must be a member of the sysadminfixed server role. 
•Note that Object Explorer only displays maintenance plans if the user is a member of the sysadminfixed server role. 
•The results generated by the maintenance tasks can be written as a report to a text file, or written to the maintenance plan tables, sysmaintplan_logand sysmaintplan_logdetail, in msdb. 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 9
MaintenancePlans–how, where, when? 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners
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 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 11
HOW: Maintenance Plan Wizard 
•Verysimple(althoughadvanced) wizard 
•Providingpossibilityfor creationsimpletaskin dozensof seconds 
•Enoughin manycases, environments 
•Limited but includemanyoptions 
•Limitations: 
•numberof databases 
•granularity 
•single tasks/ no multitasking 
•no scriptingfor anotherinstances 
•someknownproblemsin previousversion of SQL Server 
•SQL Server 2005 Service Pack 2 / SQL Server 2008 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 12
HOW: Maintenance Plan Designer 
•More flexible and advanced tool (not on this session) 
•Graphical user interface with SSIS 
•Most often used for „real DBA” 
•Increased features 
•Workflow for specified tasks with execution plan 
•Multitasking 
•Two additional Maintenance plans 
•ExecuteT-SQL Statement 
•Notify Operator 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 13
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 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 14
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/ 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 15
Maintenance Plan: replacement 
•TheSQLServerMaintenanceSolutioncomprisesscriptsforrunningbackups,integritychecks,andindexandstatisticsmaintenanceonalleditionsofMicrosoftSQLServer2005,SQLServer2008, SQLServer2008R2,SQLServer2012,andSQLServer2014. 
•Thesolutionisbasedonstoredprocedures,thesqlcmdutility,andSQLServerAgentjobs.Idesignedthesolutionforthemostmission-criticalenvironments,anditisusedinmanyorganizationsaroundtheworld. 
•NumerousSQLServercommunityexpertsrecommendtheSQLServerMaintenanceSolution, whichhasbeenaGoldwinnerinthe2013,2012,2011,and2010SQLServerMagazineAwards. TheSQLServerMaintenanceSolutionisfree. 
“After you review this checklist run —do not walk —over to this website: http://ola.hallengren.com. Download, read, understand and implement these scripts. My friend Ola has done a better job on these scripts than I’ve seen anywhere else, hands down.”-Buck Woody 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 16
(Everything I do) Ido it for you 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners
Maintenance plans: availabletasks 
•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| usingmsdb, don’t do that too much frequently 
•Execute SQL Server Agent Job | providingscripts using wen youwork with agent 
•BackUpDatabase (Full) | executingBACKUP DATABASE with FULL option>>TransactionLog 
•BackUpDatabase (Differential) | executingBACKUP DATABASE with DIFFERENTIAL option 
•BackUpDatabase (TransactionLog) | executingBACKUP LOG, frequency... 
•MaintenanceCleanupTask| most complicated feature ? BAK, TRN, TXT 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 18
Functionality: Verify Integrityof Database 
•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 
Y O U S H O U L D R E M E M B E R 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 19
POSSIBILITIES: SHRINK DATABASE 
NEVER USE THIS OPTION IN MAINTENANCE PLANS 
•AutomatedDatabase Shrinking: 
•When the AUTO_SHRINKdatabase option has been set to ON, the Database Engine automatically shrinks databases that have free space. 
•This option is set using the ALTER DATABASE statement. By default, it is set to OFF. 
•Manual Database Shrinking: 
•If a DBCC SHRINKDATABASE or DBCC SHRINKFILE statement cannot reclaim all the specified space in a log file, the statement will issue an informational message that indicates what action you must perform to make more space eligible to be freed. 
•When using the DBCC SHRINKDATABASE statement, you cannot shrink a whole database to be smaller than its original size. 
•Therefore, if a database was created with a size of 10 MB and grew to 100 MB, the smallest the database could be reduced to is 10 MB, even if all the data in the database has been deleted. 
Y O U M U S T R E M E M B E R 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 20
POSSIBILITIES: SHRINK DATABASE 
Twoverygoodpostsaboutshrinkingdatabasesand otherlinks: 
•Shrinking a Database (TechNet): 
•http://technet.microsoft.com/en-us/library/ms189080(v=SQL.105).aspx 
•Pinal Dave: SQL SERVER –Shrinking Database is Bad –Increases Fragmentation –Reduces Performance 
•http://blog.sqlauthority.com/2011/01/19/sql-server-shrinking-database-is-bad-increases- fragmentation-reduces-performance/ 
•Brent Ozar: Stop Shrinking Your Database Files. Seriously. Now. 
•http://www.brentozar.com/archive/2009/08/stop-shrinking-your-database-files-seriously-now/ 
Y O U M U S T R E M E M B E R 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 21
POSSIBILITIES: Maintain Index & Column Statistics 
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 
Y O U S H O U L D R E M E M B E R 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 22
POSSIBILITIES: Reorganize vs rebuild 
Reorganize Index Task 
Rebuild Index Task 
removing empty space and logical fragmentation 
Performs a less thorough index defragmentation than Rebuild Index. If an index does not have any fragmentation, then is not reoganized, saving resources. 
Virtually all wasted free space and logical fragmentation is removed. All indexes are rebuild from scratch, whether they need it or not. 
performance impact 
does not require long blocking locks. An online task that allows users to access the database duringthetask 
requires potentially long blocking locks that prevent users from accessing the indexes being rebuilt. A task that should be performed offline, though with the Enterprise Edition of SQL Server, you can use the online version of an index 
speed 
generally takes longer to run that the Rebuild Index Task 
Generally runs faster than Reorganize Index Task 
space requirements 
Uses less disk space that the Rebuild Index Task. Uses less space i the transaction log than Rebuild Index Task 
Use more disk space than Reorganize Index Task. More space is required in the transaction log than the Reorganize Index. 
statistics maintenance 
Index and column statistics must be updated separately. This adds to the administration hassle. 
Index and column statistic are automatically updated as part of this step, using FULLSCANN option 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 23
POSSIBILITIES: history clean up (MSDB) 
Choosingthe data (right data) for deleting: 
•Backup and restorehistory 
•SQL Server Agent jobhistory 
•MaintenancePlan history 
Y O U M U S T R E M E M B E R 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 24
PHASE two–showtime
Summary 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners
PHASE THREE -discussion
SUMMARY 
•We should remember about: 
•Task sequences 
•Task execution 
•Task priority 
•Documentation 
•Using: daily / weekly / occasionally 
•We getbetterexpoloration of our environment 
•We canmonitoring / (partially) of performance and space 
•Standard and above (sorry) 
•Maintenance Plan Wizard 
•for beginners and small installations 
•Maintenance Plan Designer 
•Adult, more complicated, wide environment 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 28
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 29
LINKS 
•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 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 30
CONTACT: 
•MAIL: KoprowskiT@windowslive.com 
•MSG: KoprowskiT@windowslive.com 
•TWITTER/FACEBOOK/LINKEDIN: KoprowskiT 
SLIDES FROM SESSION: 
•SQL Relay2014 Page: https://www.sqlrelay.co.uk/ 
•SlideShareProfile: http://www.slideshare.net/Anorak 
BLOGS: 
•ITPRO Anorak’sVision: http://itblogs.pl/notbeautifulanymore/[PL/EN] 
•Volume LicensingSpecialites: http://koprowskit.eu/licensing/[PL] 
•My MVP Blog: http://koprowskit.eu/geek/[EN/ES/PL] 
AFTER SESSION 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 31
Premier 
Gold 
Silver 
Bronze 
Our awesome sponsors
Diolch yn fawr 
PleaserememberaboutFeedback and raffle 
SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 33

KoprowskiT_SQLRelay2014#4_Caerdydd_MaintenancePlansForBeginners

  • 1.
    Premier Gold Silver Bronze Our awesome sponsors
  • 2.
  • 3.
  • 4.
    ABOUT ME •Leaderof Polish SQL Server User Group •Microsoft CertifiedTrainer(SharePoint, SQL Server, Security, Azure) •SQL Server MVP (five years) •MVP Mentor Program Member •consultant, security& licensingauditor •activeblogger, influencer, technicalwriter •last9 yearslivingin Data Processing Center •last14 yearsbanking and ICT •NOW goingintoIndependent Consultancy •frequentlyspeaker atseveralconferences: SQL Server Community Launch, Time for SharePoint, CodeCamps, InfoMEET, SharePoint Community Launch, CISSP Day, SQL in the City, InfoTRAMS, SQL Bits, IT Camp, SQL Saturday, CareerCon, Sharepoint& SQL Connection, Kariera IT, SQL Rally, SQL Relay, InfoTech… •Microsoft TerminologyCommunity/ translationsfor Wndows7/8 and Visual Studio 2010/2012 SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 4
  • 5.
    AGENDA PHASE ONE–slidetalks •MP–whatwe aretalkingabout? •MP –how, where, when? •MP -methods, tools, right (?) ways •whatMaintenance Plans can do you You PHASE TWO –show time PHASE THREE –discussiontime SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 5
  • 6.
  • 7.
    MaintenancePlans–whatwe aretalkingabout? SQLRelay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners
  • 8.
    Maintenance Plans –whatare you talking about? •Clean Environment •Silence •Knowledge about environment •Productivity / Performance DEFINITION: A database maintenance plan is a set of specific, proactivetask thatneed to be performedregularlyon databases to ensuretheiradequate performance and availability SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 8
  • 9.
    Maintenance Plans –whatare you talking about? •To create or manage maintenance plans you must be a member of the sysadminfixed server role. •Note that Object Explorer only displays maintenance plans if the user is a member of the sysadminfixed server role. •The results generated by the maintenance tasks can be written as a report to a text file, or written to the maintenance plan tables, sysmaintplan_logand sysmaintplan_logdetail, in msdb. SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 9
  • 10.
    MaintenancePlans–how, where, when? SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners
  • 11.
    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 SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 11
  • 12.
    HOW: Maintenance PlanWizard •Verysimple(althoughadvanced) wizard •Providingpossibilityfor creationsimpletaskin dozensof seconds •Enoughin manycases, environments •Limited but includemanyoptions •Limitations: •numberof databases •granularity •single tasks/ no multitasking •no scriptingfor anotherinstances •someknownproblemsin previousversion of SQL Server •SQL Server 2005 Service Pack 2 / SQL Server 2008 SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 12
  • 13.
    HOW: Maintenance PlanDesigner •More flexible and advanced tool (not on this session) •Graphical user interface with SSIS •Most often used for „real DBA” •Increased features •Workflow for specified tasks with execution plan •Multitasking •Two additional Maintenance plans •ExecuteT-SQL Statement •Notify Operator SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 13
  • 14.
    LIMITATIONS: Maintenance Planwizard & 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 SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 14
  • 15.
    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/ SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 15
  • 16.
    Maintenance Plan: replacement •TheSQLServerMaintenanceSolutioncomprisesscriptsforrunningbackups,integritychecks,andindexandstatisticsmaintenanceonalleditionsofMicrosoftSQLServer2005,SQLServer2008, SQLServer2008R2,SQLServer2012,andSQLServer2014. •Thesolutionisbasedonstoredprocedures,thesqlcmdutility,andSQLServerAgentjobs.Idesignedthesolutionforthemostmission-criticalenvironments,anditisusedinmanyorganizationsaroundtheworld. •NumerousSQLServercommunityexpertsrecommendtheSQLServerMaintenanceSolution, whichhasbeenaGoldwinnerinthe2013,2012,2011,and2010SQLServerMagazineAwards. TheSQLServerMaintenanceSolutionisfree. “After you review this checklist run —do not walk —over to this website: http://ola.hallengren.com. Download, read, understand and implement these scripts. My friend Ola has done a better job on these scripts than I’ve seen anywhere else, hands down.”-Buck Woody SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 16
  • 17.
    (Everything I do)Ido it for you SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners
  • 18.
    Maintenance plans: availabletasks •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| usingmsdb, don’t do that too much frequently •Execute SQL Server Agent Job | providingscripts using wen youwork with agent •BackUpDatabase (Full) | executingBACKUP DATABASE with FULL option>>TransactionLog •BackUpDatabase (Differential) | executingBACKUP DATABASE with DIFFERENTIAL option •BackUpDatabase (TransactionLog) | executingBACKUP LOG, frequency... •MaintenanceCleanupTask| most complicated feature ? BAK, TRN, TXT SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 18
  • 19.
    Functionality: Verify IntegrityofDatabase •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 Y O U S H O U L D R E M E M B E R SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 19
  • 20.
    POSSIBILITIES: SHRINK DATABASE NEVER USE THIS OPTION IN MAINTENANCE PLANS •AutomatedDatabase Shrinking: •When the AUTO_SHRINKdatabase option has been set to ON, the Database Engine automatically shrinks databases that have free space. •This option is set using the ALTER DATABASE statement. By default, it is set to OFF. •Manual Database Shrinking: •If a DBCC SHRINKDATABASE or DBCC SHRINKFILE statement cannot reclaim all the specified space in a log file, the statement will issue an informational message that indicates what action you must perform to make more space eligible to be freed. •When using the DBCC SHRINKDATABASE statement, you cannot shrink a whole database to be smaller than its original size. •Therefore, if a database was created with a size of 10 MB and grew to 100 MB, the smallest the database could be reduced to is 10 MB, even if all the data in the database has been deleted. Y O U M U S T R E M E M B E R SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 20
  • 21.
    POSSIBILITIES: SHRINK DATABASE Twoverygoodpostsaboutshrinkingdatabasesand otherlinks: •Shrinking a Database (TechNet): •http://technet.microsoft.com/en-us/library/ms189080(v=SQL.105).aspx •Pinal Dave: SQL SERVER –Shrinking Database is Bad –Increases Fragmentation –Reduces Performance •http://blog.sqlauthority.com/2011/01/19/sql-server-shrinking-database-is-bad-increases- fragmentation-reduces-performance/ •Brent Ozar: Stop Shrinking Your Database Files. Seriously. Now. •http://www.brentozar.com/archive/2009/08/stop-shrinking-your-database-files-seriously-now/ Y O U M U S T R E M E M B E R SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 21
  • 22.
    POSSIBILITIES: Maintain Index& Column Statistics 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 Y O U S H O U L D R E M E M B E R SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 22
  • 23.
    POSSIBILITIES: Reorganize vsrebuild Reorganize Index Task Rebuild Index Task removing empty space and logical fragmentation Performs a less thorough index defragmentation than Rebuild Index. If an index does not have any fragmentation, then is not reoganized, saving resources. Virtually all wasted free space and logical fragmentation is removed. All indexes are rebuild from scratch, whether they need it or not. performance impact does not require long blocking locks. An online task that allows users to access the database duringthetask requires potentially long blocking locks that prevent users from accessing the indexes being rebuilt. A task that should be performed offline, though with the Enterprise Edition of SQL Server, you can use the online version of an index speed generally takes longer to run that the Rebuild Index Task Generally runs faster than Reorganize Index Task space requirements Uses less disk space that the Rebuild Index Task. Uses less space i the transaction log than Rebuild Index Task Use more disk space than Reorganize Index Task. More space is required in the transaction log than the Reorganize Index. statistics maintenance Index and column statistics must be updated separately. This adds to the administration hassle. Index and column statistic are automatically updated as part of this step, using FULLSCANN option SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 23
  • 24.
    POSSIBILITIES: history cleanup (MSDB) Choosingthe data (right data) for deleting: •Backup and restorehistory •SQL Server Agent jobhistory •MaintenancePlan history Y O U M U S T R E M E M B E R SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 24
  • 25.
  • 26.
    Summary SQL Relay2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners
  • 27.
  • 28.
    SUMMARY •We shouldremember about: •Task sequences •Task execution •Task priority •Documentation •Using: daily / weekly / occasionally •We getbetterexpoloration of our environment •We canmonitoring / (partially) of performance and space •Standard and above (sorry) •Maintenance Plan Wizard •for beginners and small installations •Maintenance Plan Designer •Adult, more complicated, wide environment SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 28
  • 29.
    SQL Relay 2014| Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 29
  • 30.
    LINKS •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 SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 30
  • 31.
    CONTACT: •MAIL: KoprowskiT@windowslive.com •MSG: KoprowskiT@windowslive.com •TWITTER/FACEBOOK/LINKEDIN: KoprowskiT SLIDES FROM SESSION: •SQL Relay2014 Page: https://www.sqlrelay.co.uk/ •SlideShareProfile: http://www.slideshare.net/Anorak BLOGS: •ITPRO Anorak’sVision: http://itblogs.pl/notbeautifulanymore/[PL/EN] •Volume LicensingSpecialites: http://koprowskit.eu/licensing/[PL] •My MVP Blog: http://koprowskit.eu/geek/[EN/ES/PL] AFTER SESSION SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 31
  • 32.
    Premier Gold Silver Bronze Our awesome sponsors
  • 33.
    Diolch yn fawr PleaserememberaboutFeedback and raffle SQL Relay 2014 | Caerdydd Oct 16th | KoprowskiT - Maintenance Plans for Beginners 33