SQL Server Optimisation Jonathan Ward (Epicor) www.epicor.com @EpicorUK
What we will cover SQL Server Version & differences Features Installation & Configuration Indexes Maintenance Backups SSRS DR 2
Versions & Differences nenterprise n+1standard Why Enterprise? SQL Server edition Enterprise Definition The premium offering, SQL Server Enterprise edition delivers comprehensive high-end datacenter capabilities with blazing-fast performance, unlimited virtualization, and end-toend business intelligence enabling high service levels for mission-critical workloads and end user access to data insights. Standard SQL Server Standard edition delivers basic data management and business intelligence database for departments and small organizations to run their applications and supports common development tools for on-premise and cloud enabling effective database management with minimal IT resources. 3
EOL 2008 SP4 09/07/2019 2008 R2 SP3-09/07/2019 2012 SP3-09/10/2018 2012 SP4 (recently released) - 12/07/2022 2014 SP2-09/07/2024 2016 SP1-14/07/2026 4
What Features do I install 5
Install Configurations Disks Purpose Size IO Requiremements C OS, Pagefile 80GB E SQL Applications 60GB F SQL DB & TempDB mdf files 200GB 150 MB/s @ <= 5ms latency G SQL Transaction Log ldf files 100GB 50 MB/s @ <= 5ms latency I SQL Backup Files 200GB 6
Configure the server Memory Cap Boost SQL Server Priority Ad-Hoc Workloads Parallelism Parameterization (DB Level) SECURITY 7
Indexes Shhhh it s a library. 8
How To Rebuild Using Maintenance Plans Rebuild/Reorganize/Update Statistics Using Other Scripts/Tools Just ASK! 9
Maintenance Plans Check it, clean it, code it Back up Database Task Check Database Integrity Task Execute SQL Server Agent Job Task Execute T-SQL Statement Task History Cleanup Task Maintenance Cleanup Task Notify Operator Task Rebuild Index Task Reorganize Index Task Shrink Database Task Update Statistics Task 10
SQL Backups Logs Differential Full Recovery Models Full Simple Bulk-Logged Plan, Script, Schedule 11
Recovery model Description Work loss exposure Recover to point in time? Simple No log backups. Automatically reclaims log space to keep space requirements small, essentially eliminating the need to manage the transaction log space. For information about database backups under the simple recovery model, see Full Database Backups (SQL Server). Operations that require transaction log backups are not supported by the simple recovery model. The following features cannot be used in simple recovery mode: -Log shipping -Always On or Database mirroring -Media recovery without data loss Changes since the most recent backup are unprotected. In the event of a disaster, those changes must be redone. Can recover only to the end of a backup. For more information, see Complete Database Restores (Simple Recovery Model). For a more in depth explanation of the Simple recovery model, see SQL Server Simple Recovery Model provided by the folks at MSSQLTips! Full Bulk logged -Point-in-time restores Requires log backups. No work is lost due to a lost or damaged data file. Can recover to an arbitrary point in time (for example, prior to application or user error). For information about database backups under the full recovery model, see Full Database Backups (SQL Server) and Complete Database Restores (Full Recovery Model). Requires log backups. An adjunct of the full recovery model that permits highperformance bulk copy operations. Reduces log space usage by using minimal logging for most bulk operations. For information about operations that can be minimally logged, see The Transaction Log (SQL Server). For information about database backups under the bulklogged recovery model, see Full Database Backups (SQL Server) and Complete Database Restores (Full Recovery Model). 12 Normally none. If the tail of the log is damaged, changes since the most recent log backup must be redone. If the log is damaged or bulk-logged operations occurred since the most recent log backup, changes since that last backup must be redone. Otherwise, no work is lost. Can recover to a specific point in time, assuming that your backups are complete up to that point in time. For information about using log backups to restore to the point of failure, see Restore a SQL Server Database to a Point in Time (Full Recovery Model). Note: If you have two or more full-recovery-model databases that must be logically consistent, you may have to implement special procedures to make sure the recoverability of these databases. For more information, see Recovery of Related Databases That Contain Marked Transaction. Can recover to the end of any backup. Point-in-time recovery is not supported.
SSRS Don t forget to maintain the ReportServer database If reporting volume is high, consider offloading to another server 13
DR Mirroring Transaction Log Shipping AlwaysOn 14
What didn t we cover? SQL Server Profiling TraceFlags 1117 - When a file in the filegroup meets the autogrow threshold, all files in the filegroup grow. 1118 - Removes most single page allocations on the server, reducing contention on the SGAM page. When a new object is created, by default, the first eight pages are allocated from different extents (mixed extents). Afterwards, when more pages are needed, those are allocated from that same extent (uniform extent) 1222 - Returns the resources and types of locks that are participating in a deadlock and also the current command affected, in an XML format that does not comply with any XSD schema. 2493 - Allows a table variable to trigger recompile when enough number of rows are changed. 15
16