【发布时间】:2013-10-11 10:41:01
【问题描述】:
数据库:Oracle 11g
我正在从事一个新建项目并设计数据库架构。我有一个审计表,顾名思义, 最终将增长到拥有大量记录。以下是表定义(修剪无关列之后)。
create table ClientAudit (
id number(19,0) primary key,
clientId number(19,0) not null,
createdOn timestamp with time zone default systimestamp not null
);
id 是由 oracle 序列填充的自然数。
clientId 是唯一的客户端标识符。
为了便于通过报告进行查询,我还创建了一个以下视图,它根据 createdOn 为每个客户提供最新记录:
create or replace view ClientAuditView
as
select * from (
select ca.*,max(ca.createdOn) keep (dense_rank last order by ca.createdOn)
over (partition by ca.clientId) maxCreatedOn
from ClientAudit ca
)
where createdOn=maxCreatedOn;
/
如果我要对 ClientAudit 表进行分区,我不确定这里的分区键应该是什么。
应该是 ClientId 还是 CreatedOn?
分区策略应该是什么?
【问题讨论】: