I'm practicing splitting a partition function on a QA box to add new partitions for the upcoming calendar year. I'm running SQL Server Enterprise edition, patch level 12.0.4100. Here is the current function definition...
CREATE PARTITION FUNCTION [PF_UTC](datetime2(7)) AS RANGE LEFT
FOR VALUES (N'2012-01-01T00:00:00.000', N'2012-04-01T00:00:00.000',
N'2012-07-01T00:00:00.000', N'2012-10-01T00:00:00.000',
N'2013-01-01T00:00:00.000', N'2013-04-01T00:00:00.000',
N'2013-07-01T00:00:00.000', N'2013-10-01T00:00:00.000',
N'2014-01-01T00:00:00.000', N'2014-04-01T00:00:00.000',
N'2014-07-01T00:00:00.000', N'2014-10-01T00:00:00.000',
N'2015-01-01T00:00:00.000', N'2015-04-01T00:00:00.000',
N'2015-07-01T00:00:00.000', N'2015-10-01T00:00:00.000',
N'2016-01-01T00:00:00.000', N'2016-04-01T00:00:00.000')
Three partition schemes were defined at the time of function creation but only the first one is utilized with data files added.
CREATE PARTITION SCHEME [PS_UTC_Clustered] AS PARTITION [PF_UTC] TO (
[Partitioned_Pre2012_Clustered]
,[Partitioned_2012Q1_Clustered]
,[Partitioned_2012Q2_Clustered]
,[Partitioned_2012Q3_Clustered]
,[Partitioned_2012Q4_Clustered]
,[Partitioned_2013Q1_Clustered]
,[Partitioned_2013Q2_Clustered]
,[Partitioned_2013Q3_Clustered]
,[Partitioned_2013Q4_Clustered]
,[Partitioned_2014Q1_Clustered]
,[Partitioned_2014Q2_Clustered]
,[Partitioned_2014Q3_Clustered]
,[Partitioned_2014Q4_Clustered]
,[Partitioned_2015Q1_Clustered]
,[Partitioned_2015Q2_Clustered]
,[Partitioned_2015Q3_Clustered]
,[Partitioned_2015Q4_Clustered]
,[Partitioned_2016Q1_Clustered]
,[Partitioned_2016Q2_Clustered]
)
CREATE PARTITION SCHEME [PS_UTC_NonClustered] AS PARTITION [PF_UTC] TO (
[Partitioned_Pre2012_NonClustered]
,[Partitioned_2012Q1_NonClustered]
,[Partitioned_2012Q2_NonClustered]
,[Partitioned_2012Q3_NonClustered]
,[Partitioned_2012Q4_NonClustered]
,[Partitioned_2013Q1_NonClustered]
,[Partitioned_2013Q2_NonClustered]
,[Partitioned_2013Q3_NonClustered]
,[Partitioned_2013Q4_NonClustered]
,[Partitioned_2014Q1_NonClustered]
,[Partitioned_2014Q2_NonClustered]
,[Partitioned_2014Q3_NonClustered]
,[Partitioned_2014Q4_NonClustered]
,[Partitioned_2015Q1_NonClustered]
,[Partitioned_2015Q2_NonClustered]
,[Partitioned_2015Q3_NonClustered]
,[Partitioned_2015Q4_NonClustered]
,[Partitioned_2016Q1_NonClustered]
,[Partitioned_2016Q2_NonClustered]
)
CREATE PARTITION SCHEME [PS_UTC_Text] AS PARTITION [PF_UTC] TO (
[Partitioned_Pre2012_Text]
,[Partitioned_2012Q1_Text]
,[Partitioned_2012Q2_Text]
,[Partitioned_2012Q3_Text]
,[Partitioned_2012Q4_Text]
,[Partitioned_2013Q1_Text]
,[Partitioned_2013Q2_Text]
,[Partitioned_2013Q3_Text]
,[Partitioned_2013Q4_Text]
,[Partitioned_2014Q1_Text]
,[Partitioned_2014Q2_Text]
,[Partitioned_2014Q3_Text]
,[Partitioned_2014Q4_Text]
,[Partitioned_2015Q1_Text]
,[Partitioned_2015Q2_Text]
,[Partitioned_2015Q3_Text]
,[Partitioned_2015Q4_Text]
,[Partitioned_2016Q1_Text]
,[Partitioned_2016Q2_Text]
)
I'm not planning on creating 2016Q3 and 2016Q4 quarters as I don't want to incur the data movement between the filegroups. I've elected to start with 1/1/2017 and create a 2017Q1 filegroup. I execute the following, anticipating that it'll be a quick meta modification.
--CREATE 2017Q1 FG
USE [master];
ALTER DATABASE [JMQ] ADD FILEGROUP [JMQ_2017Q1];
--ADD 2017Q1 Data Files
ALTER DATABASE [JMQ] ADD FILE (
NAME = N'JMQ_2017Q1_01'
,FILENAME = N'M:\DATA\mssql\data\JMQ_2017Q1_01.ndf'
,SIZE = 1024000 KB
,FILEGROWTH = 1024000 KB
) TO FILEGROUP [JMQ_2017Q1]
--ALTER PARTITION SCHEME NEXT USED FOR NEW FG
USE [JMQ];
ALTER PARTITION SCHEME PS_UTC_Clustered NEXT USED [JMQ_2017Q1];
USE [JMQ];
ALTER PARTITION SCHEME PS_UTC_NonClustered NEXT USED [JMQ_2017Q1];
USE [JMQ];
ALTER PARTITION SCHEME PS_JMQ_UTC_Text NEXT USED [JMQ_2017Q1];
--ALTER PARTITION FUNCTION TO SPLIT RANGE ON 1/1/17 00:00:00
USE [JMQ];
ALTER PARTITION FUNCTION PF_UTC () SPLIT RANGE ('2017-01-01 00:00:00')
But right now, it's been running for 90 minutes. I'm watching via Spotlight that the new data file is being populated. I spot-check the UTC dates on all the tables in the DB in Prod and confirm nothing is dated after 1/1/2017. I can understand the engine needing to seek/scan indexes to confirm nothing has to move to the FG, but if no records are qualified to move, why all the data movement?