小编Rob*_*man的帖子

SQL Server 分区 - 分区键使用什么?

我从来没有使用过 SQL Server 分区,但我目前面临着设计一个卷可能需要它的数据库。该系统用于优惠券。优惠券将定期发行,通常每六周发行一次,但也会有临时发行——例如特殊活动。有1500万客户,每一次发行活动,每个客户将获得6种不同的优惠券类型,共计9000万张优惠券实例。我们需要跟踪优惠券实例兑换数据并将其保持 6 个月,尽管通常优惠券的有效期仅为 6 周。任何对无效优惠券的兑换请求都不会到达数据库,因为它将由 POS 直到验证。

在六个月的时间里,我们需要在 Coupon Instance 表中存储 3.6 亿行,在 Redemption 表中存储多达 7200 万行(假设最高 20% 的赎回率)。我觉得这些数字对于单个分区来说太大了?

我的问题是 - 使用什么作为分区键?一个明显的候选者是发行事件,给出大约 6 个分区。但是我认为即使这样也会导致分区大小太大而无法实现最佳性能?是否可以通过两个键进行分区,例如通过发行事件 + 客户 ID 的最后一位数字?所以逻辑是:

If issuance event = 1 and last digit of customer id < 5 then
    Store in partition 1
Else if issuance event = 1 and last digit of customer id >4 then
    Store in partition 2
Else if issuance event =2 and last digit of customer id <5 then …
Run Code Online (Sandbox Code Playgroud)

sql-server partitioning

11
推荐指数
2
解决办法
9445
查看次数

标签 统计

partitioning ×1

sql-server ×1