DB2数据库表分区的讨论
2006-03-27 22:08:00 来源:WEB开发网核心提示:3000sunqin 和hujingyu两位大虾,请教一个概念,DB2数据库表分区的讨论,分区键的功能就是用来指示相应的数据在哪个数据库分区上的,也就是说是数据库分布在不同的节点上, 不对之处请大家多多指点,大家共同学习,通过节点组分布表空间,在上面进行数据分布
3000sunqin 和hujingyu 两位大虾,请教一个概念。分区键的功能就是用来指示相应的数据在哪个数据库分区上的,也就是说是数据库分布在不同的节点上,通过节点组分布表空间,在上面进行数据分布。
1、在节点组这一层,没有问题
2、分布表空间指定了每个节点的容器,数据以hash的方式分布于容器中
3、建表的时候指定了表空间,则表数据以hash的方式分布于表空间容器中
4、建表的时候指定PARTITIONING KEY (MIX_INT) USING HASHING,数据不能够分布在不同的表空间吧。
5、对于表空间,分布在不同的节点上,你能指定表数据存储在哪个节点的容器上,我认为不可以。
6、之所以作分区,是为了提高性能,但是如果按照这种方法,应该还是要操作整个表,而不是一个表的分区
我们可以看一个Oracle(大型网站数据库平台)数据库的分区例子,
CREATE TABLE FO_GINCALL
(
DAY_ID NUMBER(,
HOUR_ID NUMBER(2),
CALLKND_ID NUMBER(4) NOT NULL,
CITYCODE_ID NUMBER(4),
FEEKND_ID NUMBER(16),
CALLTIME VARCHAR2(14 BYTE) NOT NULL,
SVC_ID VARCHAR2(20 BYTE) NOT NULL,
OPPOSENUMBER VARCHAR2(20 BYTE) NOT NULL,
BALANCE NUMBER(12,2),
CALLDURATION NUMBER(12),
CALLFEE NUMBER(12,2),
FEATUREFLAG NUMBER(1),
BEARERFLAG NUMBER(1),
FORWARDINGFLAG NUMBER(1),
ISFIRSTCALL NUMBER(1),
TIMESTAMP DATE,
SUBPARTNO NUMBER(2) NOT NULL
)
TABLESPACE TBS_ODS
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 60
STORAGE (
INITIAL 300M
MINEXTENTS 1
MAXEXTENTS 255
PCTINCREASE 0
NOLOGGING
PARTITION BY RANGE (SUBPARTNO)
(
PARTITION P_GINCALL_01 VALUES LESS THAN (2)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN01
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_02 VALUES LESS THAN (3)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN02
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_03 VALUES LESS THAN (4)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN03
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_04 VALUES LESS THAN (5)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN04
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_05 VALUES LESS THAN (6)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN05
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_06 VALUES LESS THAN (7)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN06
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_07 VALUES LESS THAN (
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN07
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_08 VALUES LESS THAN (9)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN08
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_09 VALUES LESS THAN (10)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN09
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_10 VALUES LESS THAN (11)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN10
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_11 VALUES LESS THAN (12)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN11
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_12 VALUES LESS THAN (13)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN12
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_13 VALUES LESS THAN (14)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN13
PCTFREE 10
INITRANS 1
MAXTRANS 60
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_14 VALUES LESS THAN (15)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN14
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_15 VALUES LESS THAN (16)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN15
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_16 VALUES LESS THAN (17)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN16
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_17 VALUES LESS THAN (1
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN17
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_18 VALUES LESS THAN (19)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN18
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_19 VALUES LESS THAN (20)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN19
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_20 VALUES LESS THAN (21)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN20
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_21 VALUES LESS THAN (22)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN21
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_22 VALUES LESS THAN (23)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN22
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_23 VALUES LESS THAN (24)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN23
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_24 VALUES LESS THAN (25)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN24
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_25 VALUES LESS THAN (26)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN25
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_26 VALUES LESS THAN (27)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN27
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_27 VALUES LESS THAN (2
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN27
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_28 VALUES LESS THAN (29)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN28
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_29 VALUES LESS THAN (30)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN29
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_30 VALUES LESS THAN (31)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN30
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
,
PARTITION P_GINCALL_31 VALUES LESS THAN (MAXVALUE)
NOLOGGING
NOCOMPRESS
TABLESPACE TBS_IN31
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 50M
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
)
NOCACHE
PARALLEL ( DEGREE DEFAULT INSTANCES 1 ;
如果我用了这样一个SQL,可以保证他只会访问分区 P_GINCALL_30 (及只对TABLESPACE TBS_IN30操作,极大的提高了性能)
SELECT DAY_ID
FROM FO_GINCALL
WHERE SUBPARTNO=30
如果按照DB2表可以分区(和Oracle(大型网站数据库平台)表分区一样,而不是按照索引、常规数据、大对象的不同表空间分布),那么也就是说上面Oracle(大型网站数据库平台)的表分区方法在DB2里面可以实现了(当然不是通过union all的视图,union all的视图可以做到这一点),请大虾指点实现方法
还有,分区数据库,就是将数据库实例分布于不同节点的数据库吧。
还有,是不是我们对表分区的概念有不同的理解。
不对之处请大家多多指点,大家共同学习,共同进步。
- ››db2 对float类型取char后显示科学计数法
- ››DB2中出现SQL1032N错误现象时的解决办法
- ››DB2 锁升级示例
- ››数据库对象——存储过程
- ››db2诊断系列之---定位锁等待问题
- ››数据库设计词汇对照表
- ››db2 命令选项解释
- ››数据库大型应用解决方案总结
- ››DB2 最佳实践: 使用 DB2 pureXML 管理 XML 数据的...
- ››DB2 9.5 SQL Procedure Developer 认证考试 735 准...
- ››DB2 9.5 SQL Procedure Developer 认证考试 735 准...
- ››DB2 9.5 SQL Procedure Developer 认证考试 735 准...
赞助商链接