{"id":71122,"date":"2017-05-27T06:20:33","date_gmt":"2017-05-27T06:20:33","guid":{"rendered":"https:\/\/www.simple-talk.com\/?p=71122"},"modified":"2021-08-24T13:39:24","modified_gmt":"2021-08-24T13:39:24","slug":"simultaneous-auto-growth-multiple-files","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/blogs\/simultaneous-auto-growth-multiple-files\/","title":{"rendered":"Simultaneous Auto-growth in Multiple Files"},"content":{"rendered":"<p>SQL Server 2016 has a new configuration to control the auto-growth of multiple files in the same filegroup. When we create several files in the same filegroup SQL Server does a round robin across the files, writing a piece of data in each of them until all the data is finally on the files.<\/p>\n<p>However, the amount of data written in each file may not be always the same. The algorithm SQL Server uses for the round robin takes into account the amount of free space in each file. Due to that, to ensure an even data distribution across the files, we need to keep\u00a0the files with the same size.<\/p>\n<p>If the auto-growth happens, one file will be bigger than the other, therefore the data distribution across the files will be unbalanced.<\/p>\n<p>Starting in SQL Server 2016 we have a solution for this problem: The filegroups now have the &#8220;autogrow_all_files&#8221; attribute.\u00a0 This attribute ensures that all files will grow together, keeping the same size.<\/p>\n<p>Let&#8217;s execute a demo, step by step.<\/p>\n<p>1) Create a new database. The statement below creates the database with two filegroups, the Primary and another one called FG1. You need to correct the path of the files before execute this statement.<\/p>\n<blockquote style=\"text-align: left\">\n<div><span style=\"font-family: Courier New;font-size: 10pt\"> <span style=\"color: blue\">CREATE<\/span>\u00a0<span style=\"color: blue\">DATABASE<\/span>\u00a0<span style=\"color: maroon\">sales<\/span>\u00a0<\/span><\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: blue\">ON<\/span>\u00a0<span style=\"color: blue\">PRIMARY<\/span>\u00a0<\/span><\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: maroon\">\u00a0 \u00a0 \u00a0 \u00a0 (<\/span><span style=\"color: blue\">NAME<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: maroon\">sales_dat<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">filename<\/span>\u00a0<span style=\"color: silver\">=<\/span> <br \/>\n <span style=\"color: red\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &#8216;C:\\MyFolder\\Sales.mdf&#8217;<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">size<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: black\">8<\/span><span style=\"color: maroon\">mb<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">maxsize<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: black\">500<\/span><span style=\"color: maroon\">mb<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">filegrowth<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: black\">20<\/span><span style=\"color: silver\">%<\/span>\u00a0<span style=\"color: maroon\">)<\/span><span style=\"color: silver\">,<\/span> <br \/>\n <span style=\"color: maroon\">filegroup<\/span>\u00a0<span style=\"color: maroon\">fg1<\/span>\u00a0<span style=\"color: green;font-style: italic\">&#8212;\u00a0Default<\/span> <br \/>\n <span style=\"color: maroon\">\u00a0 \u00a0 \u00a0 \u00a0 (<\/span><span style=\"color: blue\">NAME<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: maroon\">sales_dat2<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">filename<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: red\">&#8216;C:\\MyFolder\\Sales2.ndf&#8217;<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">size<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: black\">8<\/span><span style=\"color: maroon\">mb<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">maxsize<\/span>\u00a0<span style=\"color: silver\">=<\/span> <br \/>\n <span style=\"color: black\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0500<\/span><span style=\"color: maroon\">mb<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">filegrowth<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: black\">20<\/span><span style=\"color: silver\">%<\/span>\u00a0<span style=\"color: maroon\">)<\/span><span style=\"color: silver\">,<\/span><\/span><\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: maroon\">\u00a0 \u00a0 \u00a0 \u00a0 (<\/span><span style=\"color: blue\">NAME<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: maroon\">sales_dat3<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">filename<\/span>\u00a0<span style=\"color: silver\">=<\/span> <br \/>\n <span style=\"color: red\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&#8216;C:\\MyFolder\\Sales3.ndf&#8217;<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">size<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: black\">8<\/span><span style=\"color: maroon\">mb<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">maxsize<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: black\">500<\/span><span style=\"color: maroon\">mb<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">filegrowth<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: black\">20<\/span><span style=\"color: silver\">%<\/span>\u00a0<span style=\"color: maroon\">)<\/span><\/span><\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: maroon\">log<\/span>\u00a0<span style=\"color: blue\">ON<\/span> <br \/>\n <span style=\"color: maroon\">\u00a0 \u00a0 \u00a0 \u00a0 (<\/span><span style=\"color: blue\">NAME<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: maroon\">sales_log<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">filename<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: red\">&#8216;C:\\MyFolder\\Sales.ldf&#8217;<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">size<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: black\">20<\/span><span style=\"color: maroon\">mb<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">maxsize<\/span>\u00a0<span style=\"color: silver\">=<\/span> <br \/>\n <span style=\"color: maroon\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0unlimited<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">filegrowth<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: black\">10<\/span><span style=\"color: maroon\">mb<\/span>\u00a0<span style=\"color: maroon\">)<\/span><span style=\"color: silver\">;<\/span> <br \/>\n <span style=\"color: maroon\">go<\/span>\u00a0<\/span><\/div>\n<div>\u00a0<\/div>\n<\/blockquote>\n<div>2) Check the filegroups configuration. The result, in the image below, shows the default value of the attribute autogrow_all_files, disabled.<\/div>\n<div>\u00a0<\/div>\n<blockquote style=\"text-align: left\">\n<div><span style=\"font-family: Courier New;font-size: 10pt\"> <span style=\"color: blue\">USE<\/span>\u00a0<span style=\"color: maroon\">sales<\/span> <br \/>\n <span style=\"color: maroon\">go<\/span> <br \/>\n <span style=\"color: blue\">SELECT<\/span>\u00a0<span style=\"color: blue\">NAME<\/span><span style=\"color: silver\">,<\/span> <span style=\"color: maroon\">is_autogrow_all_files<\/span> <br \/>\n <span style=\"color: blue\">FROM<\/span>\u00a0\u00a0\u00a0<span style=\"color: maroon\">sys<\/span><span style=\"color: silver\">.<\/span><span style=\"color: maroon\">filegroups<\/span>\u00a0 <\/span><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-71127\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/05\/AutogrowthAll05.png\" alt=\"Configura\u00e7\u00e3o dos filegroups\" width=\"283\" height=\"108\" \/><\/p><\/blockquote>\n<p>3) Let&#8217;s create a table in filegroup FG1, insert 2000 records and check the database files. The autogrowth didn&#8217;t happen yet.<\/p>\n<blockquote style=\"text-align: left\">\n<div><span style=\"font-family: Courier New;font-size: 10pt\"> <span style=\"color: blue\">CREATE<\/span>\u00a0<span style=\"color: blue\">TABLE<\/span>\u00a0<span style=\"color: maroon\">test<\/span>\u00a0<br \/>\n \u00a0\u00a0<span style=\"color: maroon\">(<\/span> <br \/>\n \u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: maroon\">id<\/span>\u00a0\u00a0\u00a0\u00a0<span style=\"color: black;font-style: italic\">INT<\/span>\u00a0<span style=\"color: blue\">IDENTITY<\/span><span style=\"color: maroon\">(<\/span><span style=\"color: black\">1<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: black\">1<\/span><span style=\"color: maroon\">)<\/span>\u00a0<span style=\"color: blue\">PRIMARY<\/span>\u00a0<span style=\"color: blue\">KEY<\/span><span style=\"color: silver\">,<\/span> <br \/>\n \u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: maroon\">texto<\/span>\u00a0<span style=\"color: black;font-style: italic\">CHAR<\/span><span style=\"color: maroon\">(<\/span><span style=\"color: black\">8000<\/span><span style=\"color: maroon\">)<\/span> <br \/>\n \u00a0\u00a0<span style=\"color: maroon\">)<\/span> <br \/>\n <span style=\"color: blue\">ON<\/span>\u00a0<span style=\"color: maroon\">fg1<\/span> <br \/>\n <span style=\"color: maroon\">go<\/span><br \/>\n <span style=\"color: blue\">INSERT<\/span>\u00a0<span style=\"color: blue\">INTO<\/span>\u00a0<span style=\"color: maroon\">test<\/span>\u00a0<br \/>\n <span style=\"color: blue\">VALUES<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: maroon\">(<\/span><span style=\"color: red\">&#8216;x&#8217;<\/span><span style=\"color: maroon\">)<\/span> <br \/>\n <span style=\"color: maroon\">go 2000<\/span><br \/>\n <span style=\"color: blue\">EXEC<\/span>\u00a0<span style=\"color: #ff0080;font-weight: bold\">Sp_helpfile<\/span> <br \/>\n <span style=\"color: maroon\">go<\/span>\u00a0<\/span><\/div>\n<div><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-71124\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/05\/AutogrowthAll02.png\" alt=\"\" width=\"807\" height=\"154\" \/><\/div>\n<\/blockquote>\n<div>4) Using the DMV &#8216;sys.dm_db_database_page_allocations&#8217; we can identify the data distribution across the files.<\/div>\n<blockquote style=\"text-align: left\">\n<div><span style=\"font-family: Courier New;font-size: 10pt\"> <span style=\"color: blue\">select<\/span>\u00a0<span style=\"color: maroon\">extent_file_id<\/span><span style=\"color: silver\">,<\/span><span style=\"color: fuchsia\"><i>count<\/i><\/span><span style=\"color: maroon\">(<\/span><span style=\"color: silver\">*<\/span><span style=\"color: maroon\">)<\/span> <br \/>\n \u00a0<span style=\"color: blue\">from<\/span> <br \/>\n <span style=\"color: maroon\">sys<\/span><span style=\"color: silver\">.<\/span><span style=\"color: #ff0080\"><b>dm_db_database_page_allocations<\/b><\/span> <br \/>\n \u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: maroon\">(<\/span><span style=\"color: fuchsia\"><i>DB_ID<\/i><\/span><span style=\"color: maroon\">(<\/span><span style=\"color: red\">&#8216;Sales&#8217;<\/span><span style=\"color: maroon\">)<\/span><span style=\"color: silver\">,<\/span><span style=\"color: fuchsia\"><i>OBJECT_ID<\/i><\/span><span style=\"color: maroon\">(<\/span><span style=\"color: red\">&#8216;test&#8217;<\/span><span style=\"color: maroon\">)<\/span><span style=\"color: silver\">,<\/span><span style=\"color: black\">1<\/span><span style=\"color: silver\">,<\/span><span style=\"color: black\">1<\/span><span style=\"color: silver\">,<\/span><span style=\"color: red\">&#8216;DETAILED&#8217;<\/span><span style=\"color: maroon\">)<\/span> <br \/>\n <span style=\"color: blue\">group<\/span>\u00a0<span style=\"color: blue\">by<\/span>\u00a0<span style=\"color: maroon\">extent_file_id<\/span><\/span><\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: maroon\">go<\/span><\/span><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-71125\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/05\/AutogrowthAll03.png\" alt=\"\" width=\"280\" height=\"107\" \/><\/p>\n<\/blockquote>\n<p>5) Let&#8217;s insert more 20 records and check the files again. The auto-growth already happened in only one of the files.<\/p>\n<blockquote style=\"text-align: left\">\n<div><span style=\"font-family: Courier New;font-size: 10pt\"> <span style=\"color: blue\">insert<\/span>\u00a0<span style=\"color: blue\">into<\/span>\u00a0<span style=\"color: maroon\">test<\/span>\u00a0<span style=\"color: blue\">values<\/span>\u00a0<span style=\"color: maroon\">(<\/span><span style=\"color: red\">&#8216;x&#8217;<\/span><span style=\"color: maroon\">)<\/span><\/span><\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: maroon\">go\u00a0<\/span><span style=\"color: black\">20<\/span><\/span><\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: blue\">exec<\/span>\u00a0<span style=\"color: #ff0080\"><b>sp_helpfile<\/b><\/span> <\/span><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-71126\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/05\/AutogrowthAll04.png\" alt=\"\" width=\"802\" height=\"163\" \/><\/p>\n<\/blockquote>\n<p>This result will unbalance the round-robin, reducing any advantage it&#8217;s creating for the environment. Let&#8217;s try the same demonstration again, this time changing the autogrow_all_files attribute of FG1 filegroup.<\/p>\n<p>1) Drop and re-create the database, changing the autogrow_all_files and checking the change. Again, you need to correct the path of the files.<\/p>\n<blockquote style=\"text-align: left\">\n<div><span style=\"font-family: Courier New;font-size: 10pt\"> <span style=\"color: blue\">use<\/span>\u00a0<span style=\"color: maroon\">master<\/span><\/span><\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: maroon\">go<\/span><\/span><\/div>\n<div>\u00a0<\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: blue\">drop<\/span>\u00a0<span style=\"color: blue\">database<\/span><span style=\"color: blue\">if<\/span>\u00a0<span style=\"color: blue\">exists<\/span>\u00a0<span style=\"color: maroon\">Sales<\/span><span style=\"color: silver\">;<\/span><\/span><\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: maroon\">go<\/span><\/span><\/div>\n<div>\u00a0<\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: blue\">CREATE<\/span>\u00a0<span style=\"color: blue\">DATABASE<\/span>\u00a0<span style=\"color: maroon\">Sales<\/span> <br \/>\n \u00a0<span style=\"color: blue\">on<\/span>\u00a0<span style=\"color: blue\">Primary<\/span> <br \/>\n \u00a0\u00a0<span style=\"color: maroon\">(<\/span><span style=\"color: blue\">NAME<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: maroon\">Sales_dat<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">FILENAME<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: red\">&#8216;C:\\MyFolder\\Sales.mdf&#8217;<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">SIZE<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: black\">8<\/span><span style=\"color: maroon\">MB<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">MAXSIZE<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: black\">500<\/span><span style=\"color: maroon\">MB<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">FILEGROWTH<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: black\">20<\/span><span style=\"color: silver\">%<\/span>\u00a0<span style=\"color: maroon\">)<\/span><span style=\"color: silver\">,<\/span> <br \/>\n \u00a0<span style=\"color: maroon\">Filegroup<\/span>\u00a0<span style=\"color: maroon\">FG1<\/span>\u00a0<span style=\"color: green\"><i>&#8212;\u00a0Default<\/i><\/span> <br \/>\n \u00a0\u00a0<span style=\"color: maroon\">(<\/span><span style=\"color: blue\">NAME<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: maroon\">Sales_dat2<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">FILENAME<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: red\">&#8216;C:\\MyFolder\\Sales2.ndf&#8217;<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">SIZE<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: black\">8<\/span><span style=\"color: maroon\">MB<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">MAXSIZE<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: black\">500<\/span><span style=\"color: maroon\">MB<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">FILEGROWTH<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: black\">20<\/span><span style=\"color: silver\">%<\/span>\u00a0<span style=\"color: maroon\">)<\/span><span style=\"color: silver\">,<\/span> <br \/>\n \u00a0\u00a0<span style=\"color: maroon\">(<\/span><span style=\"color: blue\">NAME<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: maroon\">Sales_dat3<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">FILENAME<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: red\">&#8216;C:\\MyFolder\\Sales3.ndf&#8217;<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">SIZE<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: black\">8<\/span><span style=\"color: maroon\">MB<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">MAXSIZE<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: black\">500<\/span><span style=\"color: maroon\">MB<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">FILEGROWTH<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: black\">20<\/span><span style=\"color: silver\">%<\/span>\u00a0<span style=\"color: maroon\">)<\/span> <br \/>\n <span style=\"color: maroon\">LOG<\/span>\u00a0<span style=\"color: blue\">ON<\/span> <br \/>\n \u00a0\u00a0<span style=\"color: maroon\">(<\/span><span style=\"color: blue\">NAME<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: maroon\">Sales_log<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">FILENAME<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: red\">&#8216;C:\\MyFolder\\Sales.ldf&#8217;<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">SIZE<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: black\">20<\/span><span style=\"color: maroon\">MB<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">MAXSIZE<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: maroon\">UNLIMITED<\/span><span style=\"color: silver\">,<\/span>\u00a0<span style=\"color: maroon\">FILEGROWTH<\/span>\u00a0<span style=\"color: silver\">=<\/span>\u00a0<span style=\"color: black\">10<\/span><span style=\"color: maroon\">MB<\/span>\u00a0<span style=\"color: maroon\">)<\/span><span style=\"color: silver\">;<\/span><\/span><\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: maroon\">go<\/span><\/span><\/div>\n<div>\u00a0<\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: blue\">alter<\/span>\u00a0<span style=\"color: blue\">database<\/span>\u00a0<span style=\"color: maroon\">Sales<\/span>\u00a0<span style=\"color: maroon\">modify<\/span>\u00a0<span style=\"color: maroon\">filegroup<\/span>\u00a0<span style=\"color: maroon\">[FG1]<\/span>\u00a0<span style=\"color: maroon\">AutoGrow_All_Files<\/span> <br \/>\n <span style=\"color: blue\">\u00a0 \u00a0 \u00a0 With\u00a0<\/span><span style=\"color: blue\">Rollback<\/span>\u00a0<span style=\"color: maroon\">Immediate<\/span><\/span><\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: maroon\">go<\/span><\/span><\/div>\n<div>\u00a0<\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: blue\">use<\/span>\u00a0<span style=\"color: maroon\">sales<\/span><\/span><\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: maroon\">go<\/span><\/span><\/div>\n<div>\u00a0<\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: blue\">select<\/span>\u00a0<span style=\"color: blue\">name<\/span><span style=\"color: silver\">,<\/span><span style=\"color: maroon\">is_autogrow_all_files<\/span> <br \/>\n \u00a0<span style=\"color: blue\">from<\/span>\u00a0<span style=\"color: maroon\">sys<\/span><span style=\"color: silver\">.<\/span><span style=\"color: maroon\">filegroup<\/span> <\/span><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-71127\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/05\/AutogrowthAll05.png\" alt=\"\" width=\"283\" height=\"108\" \/><\/p>\n<\/blockquote>\n<p>2) Create the table, insert 2000 records and check the files.<\/p>\n<blockquote style=\"text-align: left\">\n<div><span style=\"font-family: Courier New;font-size: 10pt\"> <span style=\"color: blue\">create<\/span>\u00a0<span style=\"color: blue\">table<\/span>\u00a0<span style=\"color: maroon\">test<\/span>\u00a0<br \/>\n <span style=\"color: maroon\">(<\/span>\u00a0<span style=\"color: maroon\">id<\/span>\u00a0<span style=\"color: black\"><i>int<\/i><\/span>\u00a0<span style=\"color: blue\">identity<\/span><span style=\"color: maroon\">(<\/span><span style=\"color: black\">1<\/span><span style=\"color: silver\">,<\/span><span style=\"color: black\">1<\/span><span style=\"color: maroon\">)<\/span>\u00a0<span style=\"color: blue\">primary<\/span>\u00a0<span style=\"color: blue\">key<\/span><span style=\"color: silver\">,<\/span> <br \/>\n \u00a0\u00a0<span style=\"color: maroon\">texto<\/span>\u00a0<span style=\"color: black\"><i>char<\/i><\/span><span style=\"color: maroon\">(<\/span><span style=\"color: black\">8000<\/span><span style=\"color: maroon\">)<\/span><span style=\"color: maroon\">)<\/span> <br \/>\n \u00a0\u00a0<span style=\"color: blue\">on<\/span>\u00a0<span style=\"color: maroon\">FG1<\/span><\/span><\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: maroon\">go<\/span><\/span><\/div>\n<div>\u00a0<\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: blue\">insert<\/span>\u00a0<span style=\"color: blue\">into<\/span>\u00a0<span style=\"color: maroon\">test<\/span>\u00a0<span style=\"color: blue\">values<\/span>\u00a0<span style=\"color: maroon\">(<\/span><span style=\"color: red\">&#8216;x&#8217;<\/span><span style=\"color: maroon\">)<\/span><\/span><\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: maroon\">go\u00a0<\/span><span style=\"color: black\">2000<\/span><\/span><\/div>\n<div>\u00a0<\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: blue\">exec<\/span>\u00a0<span style=\"color: #ff0080\"><b>sp_helpfile<\/b><\/span><\/span><\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: maroon\">go<\/span> <\/span><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-71128\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/05\/AutogrowthAll06.png\" alt=\"\" width=\"800\" height=\"159\" \/><\/p>\n<\/blockquote>\n<p>3) Insert 20 more records and check the files again. Now the auto-growth happened in both files, keeping the data distribution even across the files.<\/p>\n<blockquote style=\"text-align: left\">\n<div><span style=\"font-family: Courier New;font-size: 10pt\"> <span style=\"color: blue\">insert<\/span>\u00a0<span style=\"color: blue\">into<\/span>\u00a0<span style=\"color: maroon\">test<\/span>\u00a0<span style=\"color: blue\">values<\/span>\u00a0<span style=\"color: maroon\">(<\/span><span style=\"color: red\">&#8216;x&#8217;<\/span><span style=\"color: maroon\">)<\/span><\/span><\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: maroon\">go\u00a0<\/span><span style=\"color: black\">20\u00a0<\/span><\/span><\/div>\n<div><span style=\"font-family: Courier New;font-size: 10pt\"><span style=\"color: blue\">exec<\/span>\u00a0<span style=\"color: #ff0080\"><b>sp_helpfile<\/b><\/span> <\/span><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-71129\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/05\/AutogrowthAll07.png\" alt=\"\" width=\"806\" height=\"160\" \/><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>SQL Server 2016 has a new configuration to control the auto-growth of multiple files in the same filegroup. When we create several files in the same filegroup SQL Server does a round robin across the files, writing a piece of data in each of them until all the data is finally on the files. However,&#8230;&hellip;<\/p>\n","protected":false},"author":50808,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2,143527],"tags":[],"coauthors":[],"class_list":["post-71122","post","type-post","status-publish","format-standard","hentry","category-blogs","category-database-administration-sql-server"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/71122","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/50808"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=71122"}],"version-history":[{"count":9,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/71122\/revisions"}],"predecessor-version":[{"id":92195,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/71122\/revisions\/92195"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=71122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=71122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=71122"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=71122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}