Deciding on a Table Partitioning Strategy
分區前思考幾個問題
Not all tables are good candidates for partitioning. If the answer is yes to all or most of
the following questions, then table partitioning is a viable database design strategy for
improving query performance. If the answer is no to most of the following questions,
then table partitioning is not the right solution for that table:
• Is the table large enough?
表足夠大?超過一千萬條記錄?
Large fact tables are good candidates for table
partitioning. If you have millions or billions of records in a table, you will see
performance benefits from logically breaking that data up into smaller chunks. For
smaller tables with only a few thousand rows or less, the administrative overhead
of maintaining the partitions will outweigh any performance benefits you might
see.
• Are you experiencing unsatisfactory performance?
查詢性能滿意否?
As with any performance tuning initiative, a table should be partitioned only if queries against that table are
producing slower response times than desired.
• Do your query predicates have identifiable access patterns?
查詢where條件有規律可循?
Examine the WHERE clauses of your query workload and look for table columns that are
consistently used to access data. For example, if most of your queries tend to look
up records by date, then a monthly or weekly date-partitioning design might be
beneficial. Or if you tend to access records by region, consider a list-partitioning
design to divide the table by region.
• Does your data warehouse maintain a window of historical data?
數據時間窗口定長?例如只保留12個月?
Another consideration for partition design is your organization’s business requirements for
maintaining historical data. For example, your data warehouse may only require
you to keep the past twelve months worth of data. If the data is partitioned by
month, you can easily drop the oldest monthly partition from the warehouse, and
load current data into the most recent monthly partition.
• Can the data be divided into somewhat equal parts based on some defining
criteria?
每個分區差不多大?
You should choose partitioning criteria that will divide your data as
evenly as possible. If the partitions contain a relatively equal number of records,
query performance improves based on the number of partitions created. For
example, by dividing a large table into 10 partitions, a query will execute 10 times
faster than it would against the unpartitioned table (provided that the partitions are
designed to support the query’s criteria).