ProProfs.

com

[CONFIGURING LOG AND DATA FILES IN SQL SERVER]

Configuring Log and Data Files
Any SQL Server 2005 database will have two file types: data files and log files. A data file or a log file can only belong to a single database.   Data Files hold data and objects (tables, indexes, etc). Log Files hold the transaction log used for tracking/recovering the database’s transactions.

Data Files Data Files can be further broken down into two separate types: 1. Primary Data Files are always included in a database; they contain startup information for the database, and contain pointers to the other files in the database. Can also hold objects/user data. The “suggested” extension for primary data files is “.mdf”. Each database can only have one primary data file.

2. Secondary Data Files are optional and user-defined. These contain objects and user data. When administering secondary data files, you can place secondary files on different physical disk drives for a boost in performance. The “suggested” extension for secondary data files is “.ndf”. Each database can have zero or more secondary data files. Best Practice: To reduce disk access contention, you should place all data and objects in secondary files and keep just the database catalog in the primary file.

Log Files You must have at least a single transaction log for every database, but you are allowed multiple log files per database to provide for faster recovery. The “suggested” extension for log files is “.ldf”. Filegroups A filegroup is simply a logical structure that allows the grouping of data files for management of multiple files as a single logical entity. For a performance boost, you can divide database objects across several filegroups, and place the filegroups on different disk subsystems.

ProProfs.com  

[CONFIGURING LOG AND DATA FILES IN SQL SERVER]

Primary Filegroup: contains the primary data file and any secondary data files that aren’t explicitly stored in another filegroup. User-defined Filegroup: Created to group secondary files, assign database objects to groups.

Every database has a default filegroup (named PRIMARY), and unless a filegroup is specified, the object is assigned to that filegroup. To alter the database’s default filegroup, issue the T-SQL statement: ALTER DATABASE [target database] MODIFY FILEGROUP [filegroup name] DEFAULT

Configuring Data Files and Log Files PRIMARY: Specifies a primary filegroup NAME: The logical name of the filegroup FILENAME: The path to the filegroup SIZE: The size of the file. MAXSIZE: The maximum size you will allow the filegroup to grow FILEGROWTH: Specifies the automatic growth interval for the file. LOG ON: Specifies information for the logfile.

ProProfs.com

[CONFIGURING LOG AND DATA FILES IN SQL SERVER]

To edit a filegroup: To edit a filegroup, specify the database you want to alter, issue the “ADD FILE” command, specify parameters like you would normally, and then specify to which filegroup you want to add the datafile to.

Configuring Database Files with RAID Systems Using RAID subsystems provides for improved performance, fault tolerance, and more storage capacity. RAID 0: Disk striping, best performance for read/write operations; no fault tolerance. RAID 1: Disk mirroring, provides fault tolerance; improves read performance, but can degrade write performance. RAID 5: Disk striping with distributed parity. Improved performance over RAID 1, but more expensive. RAID 10 (RAID 1+0): A mirror of a striped set (combines both speed and fault tolerance)

For a comparison on RAID levels, visit: http://msdn2.microsoft.com/en-us/library/ms178048.aspx

Overview of Best Practices Do not put data files on the same drive as the OS files. Place transaction log files on a different drive than the data files. Place tempdb database on a separate drive (RAID 10 or RAID 5 system).