IT tutorials
 
Technology
 

SQL Server 2008 : Data management - Filegroups - Backup and restore flexibility

10/1/2013 1:53:45 AM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

Before we cover recommended filegroup configurations, let's look at some of the ways in which filegroups are used (and abused), beginning with controlling object placement.

1. Controlling object placement

A common performance-tuning recommendation is to create tables on one filegroup and indexes on another (or some other combination), with each filegroup containing files on dedicated disks. For example, Filegroup 1 (tables) contains files on a RAID volume containing 10 disks with Filegroup 2 (indexes) containing files on a separate RAID volume, also containing 10 disks.

The theory behind such configurations is that groups of disks will operate in parallel to improve throughput. For example, disks 1–10 will be dedicated to table scans and seeks while index scans and seeks can operate in parallel on another dedicated group of disks.

Although it's true that this can improve performance in some cases, it's also true that in most cases it's a much better option to have simpler filegroup structures containing more disks. In the previous example, the alternative to two filegroups each containing 10 disks is to have one filegroup containing 20. In simpler configurations such as this, each database object has more disk spindles to be striped across.

Generally speaking, unless the data access patterns are very well known, simpler filegroup structures are almost always a better alternative, unless alternate configurations can be proven in load-testing environments.

Another common use for filegroups is for backup and restore flexibility.

2. Backup and restore flexibility

Filegroups offer a way of bringing a database online before the full database restore operation is complete. Known as piecemeal restore, this feature is invaluable in reducing downtime in recovery situations.

Without going into too much detail, piecemeal restores enable the restore process to be prioritized by filegroup. For example, after you restore a filegroup containing objects required for data entry, you can make a database available to users, after which you can restore an archive filegroup in the background. As long as the users don't require access to any of the data in the archive filegroup, they won't be affected. Therefore, the user impact is reduced by bringing the database online much faster than waiting for the full database to be restored.

Figure 1. A recommended filegroup structure with all user objects stored in a (default) secondary filegroup
 

The first part of a piecemeal restore is to restore the primary filegroup, after which individual filegroups can be restored in priority order. To speed up this process, best practice dictates avoiding the use of the primary filegroup for storing user objects. The best way of enabling this is to create a secondary filegroup immediately after creating a database and marking it as the default filegroup. Such a configuration, as shown in figure 1, ensures that the only objects stored in the primary filegroup are system objects, therefore making this very small, and in turn providing the fastest piecemeal restore path.

Listing 1 contains the T-SQL code to create a Sales database using the filegroup structure just covered. We'll create two additional filegroups: one called POS (which we'll mark as the default) and the other called Archive. The POS filegroup will contain two files and the Archive filegroup a single file.

Example 1. Create a multi-filegroup database
CREATE DATABASE [SALES] ON PRIMARY
( NAME = N'Sales'
, FILENAME = N'E:\SQL Data\MSSQL10.SALES\MSSQL\DATA\SalesDb.mdf'
, SIZE = 51200KB
, FILEGROWTH = 1024KB
)
, FILEGROUP [POS]
( NAME = N'Sales1'
, FILENAME = N'E:\SQL Data\MSSQL10.SALES\MSSQL\DATA\SalesDb1.mdf'
, SIZE = 51200KB
, FILEGROWTH = 1024KB
)
,( NAME = N'Sales2'
, FILENAME = N'E:\SQL Data\MSSQL10.SALES\MSSQL\DATA\SalesDb2.mdf'
, SIZE = 51200KB
, FILEGROWTH = 1024KB
)
, FILEGROUP [ARCHIVE]
( NAME = N'Sales3'
, FILENAME = N'E:\SQL Data\MSSQL10.SALES\MSSQL\DATA\SalesDb3.mdf'

, SIZE = 51200KB
, FILEGROWTH = 1024KB
)
LOG ON
(
NAME = N'SalesLog'
, FILENAME = N'F:\SQL Log\SalesDbLog.ldf'
, SIZE = 51200KB
, FILEGROWTH = 1024KB
)
GO

ALTER DATABASE [SALES]
MODIFY FILEGROUP [POS] DEFAULT
GO

By specifying POS as the default filegroup, we'll avoid storing user objects in the primary filegroup and thus enable the fastest piecemeal restore process. Any object creation statement (such as a CREATE TABLE command) will create the object in the POS filegroup unless another filegroup is explicitly specified as part of the creation statement.


 
Others
 
- SQL Server 2008 : Database file configuration (part 2) - Multiple data files, Sizing database files
- SQL Server 2008 : Database file configuration (part 1) - Volume separation
- Active Directory 2008 : Installing and Managing Trees and Forests - Creating Domain Trees and Forests (part 3) - Joining a New Domain Tree to a Forest
- Active Directory 2008 : Installing and Managing Trees and Forests - Creating Domain Trees and Forests (part 2) - Creating a Domain Tree
- Active Directory 2008 : Installing and Managing Trees and Forests - Creating Domain Trees and Forests (part 1) - Planning Trees and Forests
- Active Directory 2008 : Installing and Managing Trees and Forests - Reasons for Creating Multiple Domains
- Microsoft Lync Server 2013 : Integration with Other Microsoft Applications
- Microsoft Lync Server 2013 : Versions and Licensing
- Microsoft Lync Server 2013 : Lync Server Overview
- Introducing Microsoft Exchange Server 2013 : The motivation to upgrade
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us