Partition Functions and Partition Schemes
This lesson explains why tables are partitioned, how partition functions and schemes define partitions, and the key rules for partitioned tables.
Learning outcomes
After completing this lesson, you will be able to:
- Explain the manageability and performance benefits of partitioning.
- Distinguish between RANGE LEFT and RANGE RIGHT boundaries.
- Identify the filegroup and unique key rules for partitioned tables.
Why partition
Partitioning is mainly a manageability feature for very large tables: data can be loaded, archived or deleted a whole partition at a time as a metadata operation, and maintenance such as index rebuilds can target one partition. Queries that filter on the partitioning column can also benefit from partition elimination, which skips partitions that cannot contain matching rows. Partitioning does not make every query faster: queries that do not filter on the partitioning column may touch every partition, and good indexes usually matter more for performance.
What partitioning gives you
Partition functions
A partition function defines boundary values for one column type. n boundaries create n + 1 partitions. RANGE RIGHT places each boundary value in the partition to its right, so boundaries are the first value of each range, which is natural for dates such as the first day of each month; RANGE LEFT places each boundary in the partition to its left, so boundaries are the last value of each range.
CREATE PARTITION FUNCTION pfMonthly (date)
AS RANGE RIGHT FOR VALUES ('2026-01-01', '2026-02-01', '2026-03-01');
-- Partitions: < 2026-01-01 | Jan | Feb | >= 2026-03-01
CREATE PARTITION SCHEME psMonthly
AS PARTITION pfMonthly ALL TO ([PRIMARY]);
CREATE TABLE Sales.Events
(
EventID bigint NOT NULL,
EventDate date NOT NULL,
Payload nvarchar(400) NULL,
CONSTRAINT PK_Events PRIMARY KEY CLUSTERED (EventDate, EventID)
) ON psMonthly (EventDate);The following diagram compares where boundary values fall.

RANGE LEFT or RANGE RIGHT?
Partition schemes and key rules
A partition scheme maps each partition of a function to a filegroup. Azure SQL Database and SQL database in Fabric support only the PRIMARY filegroup, so schemes use ALL TO ([PRIMARY]); SQL Server can place old partitions on cheaper storage. The table is created ON scheme(column). The partitioning column must be part of the key of every unique index, including the primary key, which is why the example's primary key is (EventDate, EventID). An index created on the same scheme is aligned; aligned indexes are required for partition switching. A table can have up to 15,000 partitions.
Schemes and keys
Choosing RANGE LEFT or RIGHT
An events table is partitioned by month on a datetime2 column, and a developer defines RANGE LEFT FOR VALUES ('2026-01-31', '2026-02-28', ...). Events at 2026-01-31 14:00 land in the February partition, which breaks monthly archiving. What should the boundaries be?
Use RANGE RIGHT with the first instant of each month, such as '2026-02-01', so every value from 2026-02-01 00:00 up to the next boundary falls in February. With RANGE LEFT and a date boundary on a datetime2 column, the boundary means midnight at the start of January 31, so any later time that day exceeds it and moves to the next partition. RANGE LEFT would need boundaries at the last possible instant of each month, which is fragile.
How many partitions do four boundary values create?
Show answer
Five: n boundaries always create n + 1 partitions.
Exam Tips
Remember for the exam
- Date ranges: RANGE RIGHT with the first day of each period.
- n boundary values create n + 1 partitions.
- Azure SQL Database: partition schemes map ALL TO ([PRIMARY]).
- The partitioning column must be in every unique index key.