Implement partition elimination

As previously described, partition aligned indexes used in queries that execute frequently can have tremendous performance gains due to partition elimination. During partition elimination, entire partitions are skipped from being read, and therefore the query plan becomes much more efficient because only rows needed by the query are read.

A query lists the Top 10 Customers by Revenue for the year 2015. Notice that the WHERE clause aligns perfectly with the partition column and one of the boundary ranges of the partition function. Only the 2015 partition should be read and the partitions for 2014 and 2016 should be eliminated from the query plan.

Top 10 Customers by Revenue for 2015
SELECT TOP 10 [Customer Key], sum([Quantity] * [Unit Price]) as Revenue
FROM [Fact].[SaleModified]
WHERE [Invoice Date Key] between ‘2015-01-01’ and ‘2015-12-31’
and [Customer Key] <> 0
GROUP BY [Customer Key]
ORDER BY Revenue DESC

The query lists the Top 10 Customers by Revenue for the year 2015. Notice that the WHERE clause aligns perfectly with the partition column and one of the boundary ranges of the partition function. Only the 2015 partition should be read and the partitions for 2014 and 2016 should be eliminated from the query plan.

Execution plan showing partition elimination
















As expected, the Actual Partition Count is equal to 1. This means that a single partition corresponding to 2015 was read and the other two partitions for 2014 and 2016 were eliminated from the execution plan. Although, a clustered index scan was performed, partition elimination still provided a performance benefit for this query because only the required 2015 year data partition was scanned.

Comments

Popular Posts

Non-blocking, semi-blocking, and blocking transforms in SSIS

Implement additive, semi-additive, and non-additive measures

Design an appropriate storage solution, including hardware, disk, and file layout