SlideShare a Scribd company logo
1 of 16
Download to read offline
Files and Filegroups
Microsoft SQL Server
Rev 1.0-1406
By Naji El Kotob
naji [@] dotnetheroes.com
www.DotNETHeroes.com
Outlines
 Introduction to SQL Server files Architecture
 Understanding Pages and Extents
 About Files and Filegroups
 Primary and Secondary Filegroups
 Using Files and Filegroups
 Read-Only Filegroups
 Rules for Designing Files and Filegroups
 Recommendations
 RAID?
 FileGroup and RAID
 Interactive in-class DEMO
 QnA
 References
Database Sample
 AdventureWorks 2012 Database
 http://msftdbprodsamples.codeplex.com
Understanding Pages and Extents
 Pages
 The fundamental unit of data storage in SQL Server is the page.
 The disk space allocated to a data file (.mdf or .ndf) in a database is logically
divided into pages numbered contiguously from 0 to n.
 Disk I/O operations are performed at the page level.
 SQL Server reads or writes whole data pages.
In SQL Server, the page size is 8 KB. This means SQL
Server databases have 128 pages per megabyte.
Each page begins with a 96-byte header that is used
to store system information about the page.
http://technet.microsoft.com/en-us/library/ms190969(v=sql.105).aspx
Understanding Pages and Extents
 Extents
 Extents are a collection of eight physically contiguous pages and are used to
efficiently manage the pages. All pages are stored in extents.
 Extents are the basic unit in which space is managed.
 An extent is eight physically contiguous pages, or 64 KB. This means SQL Server
databases have 16 extents per megabyte.
A new table or index is generally allocated
pages from mixed extents. When the table
or index grows to the point that it has eight
pages, it then switches to use uniform
extents for subsequent allocations http://technet.microsoft.com/en-us/library/ms190969(v=sql.105).aspx
Files and Filegroups
 SQL Server maps a database over a set of
operating-system files.
 Data and log information are never mixed
in the same file, and individual files are
used only by one database.
 Filegroups are named collections of files
and are used to help with data placement
and administrative tasks such as backup
and restore operations.
http://technet.microsoft.com/en-us/library/ms179316(v=sql.105).aspx
Files default Extensions
 .MDF = Master Database File
 .LDF = Log Database File
 .NDF = Secondary Database File
Primary and Secondary Filegroups
 A primary filegroup contains the primary datafile (mdf).
 Tip: All system tables are allocated to the primary filegroup.
 A secondary filegroup (also called a user-defined filegroup) contains
secondary datafiles (ndf) and database objects.
 The default filegroup contains objects which were created without an
assigned filegroup.
 Tip: The primary filegroup is the default filegroup unless another filegroup is specified.
 Logfiles (.ldf) are never part of a filegroup.
Using Files and Filegroups
 File and Filegroup Fill Strategy
 Filegroups use a proportional fill strategy across all the files within each filegroup.
 For example, if file f1 has 100 MB free and file f2 has 200 MB free, one extent is allocated from file f1, two extents
from file f2, and so on. In this way, both files become full at about the same time, and simple striping is achieved.
 Improving Database Performance
 Using files and filegroups improves database performance, because it lets a database be created across multiple disks,
multiple disk controllers, or RAID (redundant array of independent disks) systems.
 Implementing Backup and Restore Strategies
 Databases made up of multiple filegroups can be restored in stages by a process known as piecemeal restore.
Read-Only Filegroups
 Any existing filegroup, except the primary filegroup, can be marked as read-
only.
 A filegroup marked read-only cannot be modified in any way.
 Tip: For tables that must not be modified, such as historical data, put them on filegroups and
then mark the filegroup as read-only. This prevents accidental updates.
Rules for Designing Files and Filegroups
 The following rules pertain to files and filegroups:
 A file or filegroup cannot be used by more than one database. For example,
file sales.mdf and sales.ndf, which contain data and objects from the sales
database, cannot be used by any other database.
 A file can be a member of only one filegroup.
 Transaction log files are never part of any filegroups.
Files and Filegroups Recommendations
 Most databases will work well with a single data file and a single transaction log file.
 If you use multiple files, create a second filegroup for the additional file and make that filegroup
the default filegroup.
 Tip: In this way, the primary file will contain only system tables and objects.
 To maximize performance, create files or filegroups on as many different available local physical
disks as possible.
 Tip: Put objects that compete heavily for space in different filegroups.
 Use filegroups to enable placement of objects on specific physical disks.
 Put different tables used in the same join queries in different filegroups.
 Tip: This will improve performance, because of parallel disk I/O searching for joined data.
 Put heavily accessed tables and the nonclustered indexes that belong to those tables on different
filegroups.
 Tip: This will improve performance, because of parallel I/O if the files are located on different physical disks.
 Do not put the transaction log file or files on the same physical disk that has the other files and
filegroups.
For more info http://technet.microsoft.com/en-us/library/ms187087(v=sql.105).aspx
RAID
http://www.gatan.com/images/knowhow/kh15_im3.png
FileGroup VS. RAID
 The best performance of your SQL Server database is to combine both multiple
Files/Filegroups and hardware RAID together.
 E.g.
 4 disks in a RAID-10 array for the data.
 2 disks using RAID-1 (mirroring) for the transaction log.
 1 disk for the non-clustered indexes
Q&A
 Please send your feedback to naji [@] dotnetheroes.com
References
 http://technet.microsoft.com/en-us/library/ms179316(v=sql.105).aspx (File
and Filegroups Architecture)
 http://www.prepressure.com/library/technology/raid
 http://macperformanceguide.com/Storage-RAID1-speed.html

More Related Content

What's hot

What's hot (20)

Active Directory Services
Active Directory ServicesActive Directory Services
Active Directory Services
 
Backup & recovery with rman
Backup & recovery with rmanBackup & recovery with rman
Backup & recovery with rman
 
Active directory
Active directoryActive directory
Active directory
 
MySQL and its basic commands
MySQL and its basic commandsMySQL and its basic commands
MySQL and its basic commands
 
Apache hive
Apache hiveApache hive
Apache hive
 
Hadoop Distributed file system.pdf
Hadoop Distributed file system.pdfHadoop Distributed file system.pdf
Hadoop Distributed file system.pdf
 
Active Directory
Active DirectoryActive Directory
Active Directory
 
Active Directory Training
Active Directory TrainingActive Directory Training
Active Directory Training
 
Active directory and application
Active directory and applicationActive directory and application
Active directory and application
 
Active Directory component
Active Directory componentActive Directory component
Active Directory component
 
MySQL innoDB split and merge pages
MySQL innoDB split and merge pagesMySQL innoDB split and merge pages
MySQL innoDB split and merge pages
 
Introduction to HDFS
Introduction to HDFSIntroduction to HDFS
Introduction to HDFS
 
RAID CONCEPT
RAID CONCEPTRAID CONCEPT
RAID CONCEPT
 
Active Directory
Active Directory Active Directory
Active Directory
 
Active Directory
Active DirectoryActive Directory
Active Directory
 
Sql Server Basics
Sql Server BasicsSql Server Basics
Sql Server Basics
 
Emc isilon overview
Emc isilon overview Emc isilon overview
Emc isilon overview
 
Sql server basics
Sql server basicsSql server basics
Sql server basics
 
Active directory
Active directory Active directory
Active directory
 
Active directory ii
Active directory   iiActive directory   ii
Active directory ii
 

Viewers also liked

Table Partitioning in SQL Server: A Magic Solution for Better Performance? (P...
Table Partitioning in SQL Server: A Magic Solution for Better Performance? (P...Table Partitioning in SQL Server: A Magic Solution for Better Performance? (P...
Table Partitioning in SQL Server: A Magic Solution for Better Performance? (P...Cathrine Wilhelmsen
 
Ms sql server architecture
Ms sql server architectureMs sql server architecture
Ms sql server architectureAjeet Singh
 
PMO OBjectives - a quick guide
PMO OBjectives - a quick guidePMO OBjectives - a quick guide
PMO OBjectives - a quick guidePM Majik
 
Introduction to microsoft sql server 2008 r2
Introduction to microsoft sql server 2008 r2Introduction to microsoft sql server 2008 r2
Introduction to microsoft sql server 2008 r2Eduardo Castro
 
Windows Server 2008 R2 Overview
Windows Server 2008 R2 OverviewWindows Server 2008 R2 Overview
Windows Server 2008 R2 OverviewAlexander Schek
 
MS Sql Server: Introduction To Database Concepts
MS Sql Server: Introduction To Database ConceptsMS Sql Server: Introduction To Database Concepts
MS Sql Server: Introduction To Database ConceptsDataminingTools Inc
 
Project Management Office (PMO)
Project Management Office (PMO)Project Management Office (PMO)
Project Management Office (PMO)Anand Subramaniam
 

Viewers also liked (8)

Table Partitioning in SQL Server: A Magic Solution for Better Performance? (P...
Table Partitioning in SQL Server: A Magic Solution for Better Performance? (P...Table Partitioning in SQL Server: A Magic Solution for Better Performance? (P...
Table Partitioning in SQL Server: A Magic Solution for Better Performance? (P...
 
Ms sql server architecture
Ms sql server architectureMs sql server architecture
Ms sql server architecture
 
PMO OBjectives - a quick guide
PMO OBjectives - a quick guidePMO OBjectives - a quick guide
PMO OBjectives - a quick guide
 
Introduction to microsoft sql server 2008 r2
Introduction to microsoft sql server 2008 r2Introduction to microsoft sql server 2008 r2
Introduction to microsoft sql server 2008 r2
 
MS-SQL SERVER ARCHITECTURE
MS-SQL SERVER ARCHITECTUREMS-SQL SERVER ARCHITECTURE
MS-SQL SERVER ARCHITECTURE
 
Windows Server 2008 R2 Overview
Windows Server 2008 R2 OverviewWindows Server 2008 R2 Overview
Windows Server 2008 R2 Overview
 
MS Sql Server: Introduction To Database Concepts
MS Sql Server: Introduction To Database ConceptsMS Sql Server: Introduction To Database Concepts
MS Sql Server: Introduction To Database Concepts
 
Project Management Office (PMO)
Project Management Office (PMO)Project Management Office (PMO)
Project Management Office (PMO)
 

Similar to Microsoft SQL Server - Files and Filegroups

Sql server lesson3
Sql server lesson3Sql server lesson3
Sql server lesson3Ala Qunaibi
 
Big data interview questions and answers
Big data interview questions and answersBig data interview questions and answers
Big data interview questions and answersKalyan Hadoop
 
Oracle Database Overview
Oracle Database OverviewOracle Database Overview
Oracle Database Overviewhonglee71
 
Ch12 OS
Ch12 OSCh12 OS
Ch12 OSC.U
 
Oracle & sql server comparison 2
Oracle & sql server comparison 2Oracle & sql server comparison 2
Oracle & sql server comparison 2Mohsen B
 
Os10
Os10Os10
Os10issbp
 
Dipping Your Toes: Azure Data Lake for DBAs
Dipping Your Toes: Azure Data Lake for DBAsDipping Your Toes: Azure Data Lake for DBAs
Dipping Your Toes: Azure Data Lake for DBAsBob Pusateri
 
SQL Server 2012 - FileTables
SQL Server 2012 - FileTables SQL Server 2012 - FileTables
SQL Server 2012 - FileTables Sperasoft
 
Hadoop File system (HDFS)
Hadoop File system (HDFS)Hadoop File system (HDFS)
Hadoop File system (HDFS)Prashant Gupta
 
Hadoop Distributed File System for Big Data Analytics
Hadoop Distributed File System for Big Data AnalyticsHadoop Distributed File System for Big Data Analytics
Hadoop Distributed File System for Big Data AnalyticsDrPDShebaKeziaMalarc
 
Big data with HDFS and Mapreduce
Big data  with HDFS and MapreduceBig data  with HDFS and Mapreduce
Big data with HDFS and Mapreducesenthil0809
 
Degonto file management
Degonto file managementDegonto file management
Degonto file managementDegonto Islam
 

Similar to Microsoft SQL Server - Files and Filegroups (20)

Sql server lesson3
Sql server lesson3Sql server lesson3
Sql server lesson3
 
6952234.ppt
6952234.ppt6952234.ppt
6952234.ppt
 
Big data interview questions and answers
Big data interview questions and answersBig data interview questions and answers
Big data interview questions and answers
 
Network data storage
Network data storageNetwork data storage
Network data storage
 
Oracle Database Overview
Oracle Database OverviewOracle Database Overview
Oracle Database Overview
 
Ch12 OS
Ch12 OSCh12 OS
Ch12 OS
 
OS_Ch12
OS_Ch12OS_Ch12
OS_Ch12
 
OSCh12
OSCh12OSCh12
OSCh12
 
Oracle & sql server comparison 2
Oracle & sql server comparison 2Oracle & sql server comparison 2
Oracle & sql server comparison 2
 
Os10
Os10Os10
Os10
 
Dipping Your Toes: Azure Data Lake for DBAs
Dipping Your Toes: Azure Data Lake for DBAsDipping Your Toes: Azure Data Lake for DBAs
Dipping Your Toes: Azure Data Lake for DBAs
 
Oracle tutorial
Oracle tutorialOracle tutorial
Oracle tutorial
 
module 2.pptx
module 2.pptxmodule 2.pptx
module 2.pptx
 
SQL Server 2012 - FileTables
SQL Server 2012 - FileTables SQL Server 2012 - FileTables
SQL Server 2012 - FileTables
 
Hadoop
HadoopHadoop
Hadoop
 
Hadoop File system (HDFS)
Hadoop File system (HDFS)Hadoop File system (HDFS)
Hadoop File system (HDFS)
 
Hadoop Distributed File System for Big Data Analytics
Hadoop Distributed File System for Big Data AnalyticsHadoop Distributed File System for Big Data Analytics
Hadoop Distributed File System for Big Data Analytics
 
Big data with HDFS and Mapreduce
Big data  with HDFS and MapreduceBig data  with HDFS and Mapreduce
Big data with HDFS and Mapreduce
 
Degonto file management
Degonto file managementDegonto file management
Degonto file management
 
Active Directory
Active DirectoryActive Directory
Active Directory
 

More from Naji El Kotob

SSRS Report with Parameters and Data Filtration
SSRS Report with Parameters and Data FiltrationSSRS Report with Parameters and Data Filtration
SSRS Report with Parameters and Data FiltrationNaji El Kotob
 
Odoo - Educational Account for Students and Teachers Ver. 2.0
Odoo - Educational Account for Students and Teachers Ver. 2.0Odoo - Educational Account for Students and Teachers Ver. 2.0
Odoo - Educational Account for Students and Teachers Ver. 2.0Naji El Kotob
 
Google search - Tips and Tricks
Google search - Tips and TricksGoogle search - Tips and Tricks
Google search - Tips and TricksNaji El Kotob
 
tempdb and Performance Keys
tempdb and Performance Keystempdb and Performance Keys
tempdb and Performance KeysNaji El Kotob
 
Microsoft SQL Server 2012 Components and Tools (Quick Overview) - Rev 1.3
Microsoft SQL Server 2012 Components and Tools (Quick Overview) - Rev 1.3Microsoft SQL Server 2012 Components and Tools (Quick Overview) - Rev 1.3
Microsoft SQL Server 2012 Components and Tools (Quick Overview) - Rev 1.3Naji El Kotob
 
T-SQL Data Types (Quick Overview)
T-SQL Data Types (Quick Overview)T-SQL Data Types (Quick Overview)
T-SQL Data Types (Quick Overview)Naji El Kotob
 
Robots and-sitemap - Version 1.0.1
Robots and-sitemap - Version 1.0.1Robots and-sitemap - Version 1.0.1
Robots and-sitemap - Version 1.0.1Naji El Kotob
 
Practical MS SQL Introduction
Practical MS SQL IntroductionPractical MS SQL Introduction
Practical MS SQL IntroductionNaji El Kotob
 
MVC and Razor - Doc. v1.2
MVC and Razor - Doc. v1.2MVC and Razor - Doc. v1.2
MVC and Razor - Doc. v1.2Naji El Kotob
 

More from Naji El Kotob (9)

SSRS Report with Parameters and Data Filtration
SSRS Report with Parameters and Data FiltrationSSRS Report with Parameters and Data Filtration
SSRS Report with Parameters and Data Filtration
 
Odoo - Educational Account for Students and Teachers Ver. 2.0
Odoo - Educational Account for Students and Teachers Ver. 2.0Odoo - Educational Account for Students and Teachers Ver. 2.0
Odoo - Educational Account for Students and Teachers Ver. 2.0
 
Google search - Tips and Tricks
Google search - Tips and TricksGoogle search - Tips and Tricks
Google search - Tips and Tricks
 
tempdb and Performance Keys
tempdb and Performance Keystempdb and Performance Keys
tempdb and Performance Keys
 
Microsoft SQL Server 2012 Components and Tools (Quick Overview) - Rev 1.3
Microsoft SQL Server 2012 Components and Tools (Quick Overview) - Rev 1.3Microsoft SQL Server 2012 Components and Tools (Quick Overview) - Rev 1.3
Microsoft SQL Server 2012 Components and Tools (Quick Overview) - Rev 1.3
 
T-SQL Data Types (Quick Overview)
T-SQL Data Types (Quick Overview)T-SQL Data Types (Quick Overview)
T-SQL Data Types (Quick Overview)
 
Robots and-sitemap - Version 1.0.1
Robots and-sitemap - Version 1.0.1Robots and-sitemap - Version 1.0.1
Robots and-sitemap - Version 1.0.1
 
Practical MS SQL Introduction
Practical MS SQL IntroductionPractical MS SQL Introduction
Practical MS SQL Introduction
 
MVC and Razor - Doc. v1.2
MVC and Razor - Doc. v1.2MVC and Razor - Doc. v1.2
MVC and Razor - Doc. v1.2
 

Recently uploaded

Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 

Recently uploaded (20)

Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 

Microsoft SQL Server - Files and Filegroups

  • 1. Files and Filegroups Microsoft SQL Server Rev 1.0-1406 By Naji El Kotob naji [@] dotnetheroes.com www.DotNETHeroes.com
  • 2. Outlines  Introduction to SQL Server files Architecture  Understanding Pages and Extents  About Files and Filegroups  Primary and Secondary Filegroups  Using Files and Filegroups  Read-Only Filegroups  Rules for Designing Files and Filegroups  Recommendations  RAID?  FileGroup and RAID  Interactive in-class DEMO  QnA  References
  • 3. Database Sample  AdventureWorks 2012 Database  http://msftdbprodsamples.codeplex.com
  • 4. Understanding Pages and Extents  Pages  The fundamental unit of data storage in SQL Server is the page.  The disk space allocated to a data file (.mdf or .ndf) in a database is logically divided into pages numbered contiguously from 0 to n.  Disk I/O operations are performed at the page level.  SQL Server reads or writes whole data pages. In SQL Server, the page size is 8 KB. This means SQL Server databases have 128 pages per megabyte. Each page begins with a 96-byte header that is used to store system information about the page. http://technet.microsoft.com/en-us/library/ms190969(v=sql.105).aspx
  • 5. Understanding Pages and Extents  Extents  Extents are a collection of eight physically contiguous pages and are used to efficiently manage the pages. All pages are stored in extents.  Extents are the basic unit in which space is managed.  An extent is eight physically contiguous pages, or 64 KB. This means SQL Server databases have 16 extents per megabyte. A new table or index is generally allocated pages from mixed extents. When the table or index grows to the point that it has eight pages, it then switches to use uniform extents for subsequent allocations http://technet.microsoft.com/en-us/library/ms190969(v=sql.105).aspx
  • 6. Files and Filegroups  SQL Server maps a database over a set of operating-system files.  Data and log information are never mixed in the same file, and individual files are used only by one database.  Filegroups are named collections of files and are used to help with data placement and administrative tasks such as backup and restore operations. http://technet.microsoft.com/en-us/library/ms179316(v=sql.105).aspx
  • 7. Files default Extensions  .MDF = Master Database File  .LDF = Log Database File  .NDF = Secondary Database File
  • 8. Primary and Secondary Filegroups  A primary filegroup contains the primary datafile (mdf).  Tip: All system tables are allocated to the primary filegroup.  A secondary filegroup (also called a user-defined filegroup) contains secondary datafiles (ndf) and database objects.  The default filegroup contains objects which were created without an assigned filegroup.  Tip: The primary filegroup is the default filegroup unless another filegroup is specified.  Logfiles (.ldf) are never part of a filegroup.
  • 9. Using Files and Filegroups  File and Filegroup Fill Strategy  Filegroups use a proportional fill strategy across all the files within each filegroup.  For example, if file f1 has 100 MB free and file f2 has 200 MB free, one extent is allocated from file f1, two extents from file f2, and so on. In this way, both files become full at about the same time, and simple striping is achieved.  Improving Database Performance  Using files and filegroups improves database performance, because it lets a database be created across multiple disks, multiple disk controllers, or RAID (redundant array of independent disks) systems.  Implementing Backup and Restore Strategies  Databases made up of multiple filegroups can be restored in stages by a process known as piecemeal restore.
  • 10. Read-Only Filegroups  Any existing filegroup, except the primary filegroup, can be marked as read- only.  A filegroup marked read-only cannot be modified in any way.  Tip: For tables that must not be modified, such as historical data, put them on filegroups and then mark the filegroup as read-only. This prevents accidental updates.
  • 11. Rules for Designing Files and Filegroups  The following rules pertain to files and filegroups:  A file or filegroup cannot be used by more than one database. For example, file sales.mdf and sales.ndf, which contain data and objects from the sales database, cannot be used by any other database.  A file can be a member of only one filegroup.  Transaction log files are never part of any filegroups.
  • 12. Files and Filegroups Recommendations  Most databases will work well with a single data file and a single transaction log file.  If you use multiple files, create a second filegroup for the additional file and make that filegroup the default filegroup.  Tip: In this way, the primary file will contain only system tables and objects.  To maximize performance, create files or filegroups on as many different available local physical disks as possible.  Tip: Put objects that compete heavily for space in different filegroups.  Use filegroups to enable placement of objects on specific physical disks.  Put different tables used in the same join queries in different filegroups.  Tip: This will improve performance, because of parallel disk I/O searching for joined data.  Put heavily accessed tables and the nonclustered indexes that belong to those tables on different filegroups.  Tip: This will improve performance, because of parallel I/O if the files are located on different physical disks.  Do not put the transaction log file or files on the same physical disk that has the other files and filegroups. For more info http://technet.microsoft.com/en-us/library/ms187087(v=sql.105).aspx
  • 14. FileGroup VS. RAID  The best performance of your SQL Server database is to combine both multiple Files/Filegroups and hardware RAID together.  E.g.  4 disks in a RAID-10 array for the data.  2 disks using RAID-1 (mirroring) for the transaction log.  1 disk for the non-clustered indexes
  • 15. Q&A  Please send your feedback to naji [@] dotnetheroes.com
  • 16. References  http://technet.microsoft.com/en-us/library/ms179316(v=sql.105).aspx (File and Filegroups Architecture)  http://www.prepressure.com/library/technology/raid  http://macperformanceguide.com/Storage-RAID1-speed.html