Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server 2005 / 2008 - multiple filegroups?

I'm a developer at heart - but every now and then, a customer doesn't have a decent DBA to deal with these issues, so I'm called in to decide....

What are your strategies / best practices when it comes to dealing with a reasonably sized SQL Server database (anything larger than Northwind or AdventureWorks) - do you use multiple filegroups? If so: how many? And why?

What are your criteria to decide when to move away from the "one filegroup for everything" approach:

  • database size?
  • database complexity?
  • availability / reliability requirements?
  • what else?

If you use multiple file groups, how many do you use? One for data, one for index, one for log? Several (how many) for data? What are your reasons for your choice - why do you use that exact number of filegroups :-)

like image 875
marc_s Avatar asked Feb 13 '09 06:02

marc_s


People also ask

What is the maximum number of filegroups that a file can belong to?

A maximum of 32,767 files and 32,767 filegroups can be specified for each database.

What is the use of having multiple filegroups?

Splitting a database across multiple filegroups permits you to take advantage of the I/O bandwidth for each physical device / path that you've placed filegroups onto.

How do I add a filegroup to an existing database?

To add a filegroup using SSMS, open SSMS and select a database where a file group needs to be created. Right-click the database select “Properties” >> select “Filegroups” and click “Add Filegroup” as shown in the following image: When we click the “Add Filegroup” button, a row will be added in the “Rows” grid.

How many types of filegroups are there in SQL Server?

SQL Server databases have three types of files, as shown in the following table. Contains startup information for the database and points to the other files in the database. Every database has one primary data file.


2 Answers

The Microsoft trained and best practice methodology is as follows:

  • Log files are placed on a separate physical drive
  • Data files are placed on a separate physical drive
  • Multiple file groups: When a particular table is extremely big. Often the case in transactional database (Separate Physical Drive)
  • Multiple file groups: When using ranges or when wanting to split lookup data into a read-only database file (Separate Physical Drive)

Keep in mind that an MDF technically works similarly to a hard drive partition when it comes to storing data. The MDF is a randomly read file, whereas the LDF is a sequentially read file. Therefore splitting them into separate drives causes a huge performance gain, unless running solid state drives, in which case the gain is still there.

like image 50
BinaryMisfit Avatar answered Nov 15 '22 22:11

BinaryMisfit


There's at least ONE good reason for having multiple (at least two) file groups in SQL Server 2008 : if you want to use the FILESTREAM feature, you have to have a dedicated and custom filegroup for your FILESTREAM data :-)

Marc

like image 37
marc_s Avatar answered Nov 15 '22 22:11

marc_s