我有一张表(t_table),该表数据量很大,而且逐年增加,每年增加的数据在200万条以上,该结构如下:
Id                  bigint NOT NULL auto_increment,
Version             int NOT NULL,
Title              VARCHAR2(100) not null,
Content            VARCHAR2(2000) not null,
ClassId        int not null,
STATE              int not null,
CreatorId           int not null,
CreateDate       DATE not null,
Degree     int,
ReplayerId        int not null,对他查询的语句如下:
select * from t_table 
where state in (1,3) and 
ClassId = 2 and
CreatorId=12 and 
ReplayerId=13 and 
CreateDate='2007-01-02' and
Degree = 1这张表该如何设计,查询效率可以更高。oracle9i,刚开始用oracle,请大家多指教!

解决方案 »

  1.   

    按createDate 建分区表 ,可以10天一个分区。 也可以 按你需要查询的这些字段建立一个索引,一年200万不算多。
      

  2.   

    createDate 是动态不断增加的,如何才能使分区也随着时间的增加,而增加呢?
      

  3.   

    如果表记录在1000万以内可以不做分区, 建立适当的索引,这个查询还是很快的. 其实表的记录多少对于取其中的少量记录查询影响不大, 只要Cardinarity高, 建立适当的索引就可以达到要求.