SQL Server 2005 / 2008 - multiple filegroups?

China☆狼群 提交于 2019-12-03 06:01:30

问题


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 :-)


回答1:


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.




回答2:


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




回答3:


Maintaining multiple filegroups helps you reduce the I/O burden. It also allows you storage flexibility where you can back up a filegroup easily rather than a single file and separate them into an individual disk drive per file group.




回答4:


Generally you should just have one Primary Filegroup and one log file against that.

Sometimes when you have very static data, you can create a SECOND filegroup that contains this static data. You can then make the filegroup READONLY which improves your performance. After all, this is pretty static data. It's not worth it if you have a low number of readonly rows (eg. lookup table values). But for some stuff (eg. archived content that can still be read in) then this might be a great option.

I got the idea from this blog post.

HTH.




回答5:


I've worked on a good range of DBs, and the only time we've used filegroups was when a disk was running short on space, and we had to create a new file group on another spindle. I'm sure there are good performance reasons why that's not ideal, but that was the reality.




回答6:


among other reasons additional filegroups make sense if you want to partition a table. and that makes sense if there are many rivaling reads with dissimilar where-conditions of that table. you can configure each partition to reflect one such where-condition and to be located on a different disk, thereby sending each read to another disk, thus parallel reads and less conflict.



来源:https://stackoverflow.com/questions/544898/sql-server-2005-2008-multiple-filegroups

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!