A partitioned table is one where the data is separated into smaller physical structures based on the value for a specific column (called the partitioning column, which is defined in the partition function). If you want to separate data by year, you might use a column called DateSold as the partitioning column, and all data for 2013 would reside in one structure, all data for 2012 would reside in a different structure, etc. These separate sets of data allow for focused maintenance (you can rebuild just a partition of an index, rather than the entire index) and permit data to be quickly added and removed because it can be staged in advance of actually being added to, or removed from, the table.

Table partitioning can make some queries slower

  • Table partitioning can make some queries slower
  • Partitioning adds complexity to troubleshooting and tuning queries– it’s time consuming and takes longer
  • Non-aligned indexes aren’t an easy answer: if we need to resort to a lot of them, how much are we actually benefitting from table partitioning?

For these reasons, table partitioning is typically not a great fit for SQL Servers with an OLTP pattern where slow queries are the biggest pain point. Traditional index tuning and query rewrites will usually get you better performance with less hassle.

Using partitioning is only going to help your query performance if the partitioning scheme is built to serve your specific queries.

You’re going to have to review your query patterns and see how they are accessing the table in order to identify the best approach. The reason for this is you can only partition on a single column (the partitioning key) and this is what will be used for partition elimination.

There are two factors that affect if partition elimination can occur and how well it will perform:

  1. Partition Key – Partitioning can only occur on a single column and your query must include that column. For example, if your table is partitioned on date and your query uses that date column, then partition elimination should occur. However, if you don’t include the partition key within the query predicate, the engine can not perform elimination.
  2. Granularity – If your partitions are to big, you won’t gain any benefit from elimination because it will still pull back more data than it needs to. However, make it to small and it becomes difficult to manage.

In many ways, partitioning is just like using any other index, with some added benefits. However, you don’t realize those benefits unless you’re dealing with incredibly large tables. Personally, I don’t even consider partitioning until my table is over 250 GB in size. Most of the time, well defined indexing will cover many of the use cases on tables smaller than that. Based on your description, you’re not seeing huge data growth, so it could be that a properly index table will perform just fine for your table.

I would strongly recommend that you review whether partitioning is actually necessary to solve your issues. One would usually partition a very large table for the purpose of:

  • Distributing data between different types of disk so that more “active” data can be placed on faster, more expensive storage while less active data is placed on cheaper, slower storage. This is mostly a cost savings measure.
  • Assisting in index maintenance for extremely large tables. Since you can rebuild partitions individually, this can assist in keeping indexes properly maintained with minimal impact.
  • Leveraging partitioning for improved archival process. See sliding windows.





Last modified: April 7, 2021



Write a Reply or Comment