j**y 发帖数: 462 | 1 我有一个表 events 可能有很多数据
我可以用Partitioning 来分子表, 例如日期,
但是我觉得还是不够高效, 例如我的表里有 active events, 和不active的
我想查询当前active events 就必须查当前的子表里的全部记录, 我觉得还是不够效
率高
1 有什么好办法?
2. 有可能实现下面的功能吗,
PARTITION p0 STATUS IS (ACTIVE) AND CREATED LESS THAN (2015)
PARTITION p1 STATUS IS NOT (ACTIVE) AND CREATED LESS THAN (2015) ,
PARTITION p1 VALUES LESS THAN (2016),
....
3.如果第二部可能实现的话,那么数据发生变化的时候,会自动重新划分到相应的子
表中去吗
例如 active -> no active
多谢多谢 | l******b 发帖数: 39 | 2 lz看这个能成马?
Composite Partitioning
Composite partitioning partitions data using the range method, and within
each partition, subpartitions it using the hash or list method.
Composite range-list partitioning provides the manageability of range
partitioning and the explicit control of list partitioning for the
subpartitions.
Composite Partitioning Range-List Example
CREATE TABLE bimonthly_regional_sales
(deptno NUMBER,
item_no VARCHAR2(20),
txn_date DATE,
txn_amount NUMBER,
state VARCHAR2(2))
PARTITION BY RANGE (txn_date)
SUBPARTITION BY LIST (state)
SUBPARTITION TEMPLATE(
SUBPARTITION east VALUES('NY', 'VA', 'FL') TABLESPACE ts1,
SUBPARTITION west VALUES('CA', 'OR', 'HI') TABLESPACE ts2,
SUBPARTITION central VALUES('IL', 'TX', 'MO') TABLESPACE ts3)
( PARTITION janfeb_2000 VALUES LESS THAN (TO_DATE('1-MAR-2000','DD-MON-YYYY'
)), PARTITION marapr_2000 VALUES LESS THAN (TO_DATE('1-MAY-2000','DD-MON-
YYYY')), PARTITION mayjun_2000 VALUES LESS THAN (TO_DATE('1-JUL-2000','DD-
MON-YYYY')) );
This statement creates a table bimonthly_regional_sales that is range
partitioned on the txn_date field and list subpartitioned on state. When you
use a template, Oracle names the subpartitions by concatenating the
partition name, an underscore, and the subpartition name from the template.
Oracle places this subpartition in the tablespace specified in the template.
In the previous statement, janfeb_2000_east is created and placed in
tablespace ts1 while janfeb_2000_central is created and placed in tablespace
ts3. In the same manner, mayjun_2000_east is placed in tablespace ts1 while
mayjun_2000_central is placed in tablespace ts3. Figure 11-5 offers a
graphical view of the table bimonthly_regional_sales and its 9 individual
subpartitions.
http://docs.oracle.com/cd/B10501_01/server.920/a96524/c12parti. | d****n 发帖数: 12461 | 3 transaction/log记录都是用时间戳来记录的,这是业务逻辑决定的。分区没法完全解
决这个事情,因为记录的东西会变化,比例也会变化,你做不到平衡。
你要查不同的事件,那就要做索引。一般可以根据时间戳的远近做三个表,分别提供不
同粒度的关键词查询功能。这也是某些商业软件实现的方式。
【在 j**y 的大作中提到】 : 我有一个表 events 可能有很多数据 : 我可以用Partitioning 来分子表, 例如日期, : 但是我觉得还是不够高效, 例如我的表里有 active events, 和不active的 : 我想查询当前active events 就必须查当前的子表里的全部记录, 我觉得还是不够效 : 率高 : 1 有什么好办法? : 2. 有可能实现下面的功能吗, : PARTITION p0 STATUS IS (ACTIVE) AND CREATED LESS THAN (2015) : PARTITION p1 STATUS IS NOT (ACTIVE) AND CREATED LESS THAN (2015) , : PARTITION p1 VALUES LESS THAN (2016),
| j**y 发帖数: 462 | 4 多谢 楼上两位
暂定分若干子表, 用时间和地区作为区分, 然后建立索引, 希望能满足效率需求 |
|