Sql-server – With multiple files in a file group, when does data start being placed on the 2nd file in the filegroup

disk-spacefilegroupssql serversql server 2014

In a previous question, it was suggested that I should add an extra "File" to my existing (Primary) Filegroup to easily add more disk space for my DB.

So I did that and nothing broke.

But I'm not sure when Sql Server will decide to stop putting data into the original File and start putting data over to the new File?

From @davidbrowne's excellent answer to my question, he mentioned:

SQL Server uses a "proportional fill algorithm" when a filegroup has multiple files.

Okay, great – but when does it 'know' to start filling the other file?

Currently, this is what I have setup … and please note the MAX FILE SIZE.

enter image description here

Do I need to give a MAX file size (e.g. LIMIT to 1T) for the original File which will then help Sql Server to 'know' when to start using the next (new) File?

There's currently 19GB left on disk F:\.

Best Answer

You'll want to preallocate the space on XWing_ExtraData. At 10MB per autogrow, it'll induce a lot of external file fragmentation and delays whenever SQL needs to expand the file on the disk (performance will be better if you have a large pre-sized file up front).

Then disable autogrowth on XWing so that it can't grow any further otherwise SQL will continue to populate the file until you run out of space, triggering an 1105 error (filegroup full).

With regards to the original file, my preference is to just disable autogrowth via the dialog box (checkbox on the top of the dialog box or via ALTER DATABASE...MODIFY FILE...FILEGROWTH=0. You want to ensure that SQL won't attempt to autogrow the file if the algorithm can choose that file instead of XWing_ExtraData if both need to autogrow to accomodate the next data insertion.