Oracle 11g 雜湊、LIST分割槽測試
在雜湊分割槽中,如果分割槽欄位的值是相同的,相同值的條目都會存放在相同的分割槽中;
LIST分割槽則易於管理,而對於雜湊分割槽,則不好控制各個值所存放的分割槽,有的分割槽會存放兩個或多個分割槽欄位值。
建立測試表
CREATE TABLE Campaign(compaign_id number, customer_name varchar2(20));
ALTER TABLE Campaign ADD primary key(compaign_id);
建立雜湊分割槽表,外來鍵引用上面建立的表
CREATE TABLE Target(request_id number,compaign_id number,
CONSTRAINT compaign_id_fk
FOREIGN KEY (compaign_id) REFERENCES Campaign(compaign_id))
PARTITION BY HASH (compaign_id)
PARTITIONS 64;
ALTER TABLE Target ADD primary key(request_id);
向第一張表中批次插入資料
BEGIN
FOR i IN 1..100 LOOP
insert into Campaign select i, dbms_random.string('U', 10) from dual;
END LOOP;
COMMIT;
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
NULL;
END;
向雜湊分割槽表中批次插入資料
BEGIN
FOR k in (select compaign_id from Campaign order by 1) LOOP
FOR i IN 1..1000 LOOP
insert into Target select dbms_random.value(1,1000000),k.compaign_id from dual;
END LOOP;
END LOOP;
COMMIT;
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
NULL;
END;
檢視執行計劃
explain plan for select * from target where COMPAIGN_ID=70;
select * from table(dbms_xplan.display);
Plan hash value: 940899126
------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 4000 | 97K| 26 (0)| 00:00:01 | | |
| 1 | PARTITION HASH SINGLE| | 4000 | 97K| 26 (0)| 00:00:01 | 42 | 42 |
|* 2 | TABLE ACCESS FULL | TARGET | 4000 | 97K| 26 (0)| 00:00:01 | 42 | 42 |
------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("COMPAIGN_ID"=70)
建立LIST分割槽表,外來鍵引用上面建立的表
CREATE TABLE Target2(request_id number,compaign_id number,
CONSTRAINT compaign_id_fk2
FOREIGN KEY (compaign_id) REFERENCES Campaign(compaign_id))
PARTITION BY LIST(compaign_id)
( PARTITION p_default VALUES (DEFAULT));
ALTER TABLE Target2 ADD primary key(request_id);
向LIST分割槽表中批次插入資料
BEGIN
FOR k in (select compaign_id from Campaign order by 1) LOOP
FOR i IN 1..1000 LOOP
insert into Target2 select dbms_random.value(1,1000000),k.compaign_id from dual;
END LOOP;
END LOOP;
COMMIT;
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
NULL;
END;
將LIST分割槽拆分,將1、50拆分成兩個單獨的分割槽
ALTER TABLE Target2 SPLIT PARTITION p_default
VALUES (1)
INTO (PARTITION p_1, PARTITION p_default);
ALTER TABLE Target2 SPLIT PARTITION p_default
VALUES (50)
INTO (PARTITION p_50, PARTITION p_default);
select count(*) from target2 partition(p_default);
檢視執行計劃
explain plan for select * from target2 where COMPAIGN_ID=50;
select * from table(dbms_xplan.display);
Plan hash value: 1725981576
-------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
-------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 5000 | 122K| 10 (0)| 00:00:01 | | |
| 1 | PARTITION LIST SINGLE| | 5000 | 122K| 10 (0)| 00:00:01 | KEY | KEY |
| 2 | TABLE ACCESS FULL | TARGET2 | 5000 | 122K| 10 (0)| 00:00:01 | 2 | 2 |
-------------------------------------------------------------------------------------------------
LIST分割槽則易於管理,而對於雜湊分割槽,則不好控制各個值所存放的分割槽,有的分割槽會存放兩個或多個分割槽欄位值。
建立測試表
CREATE TABLE Campaign(compaign_id number, customer_name varchar2(20));
ALTER TABLE Campaign ADD primary key(compaign_id);
建立雜湊分割槽表,外來鍵引用上面建立的表
CREATE TABLE Target(request_id number,compaign_id number,
CONSTRAINT compaign_id_fk
FOREIGN KEY (compaign_id) REFERENCES Campaign(compaign_id))
PARTITION BY HASH (compaign_id)
PARTITIONS 64;
ALTER TABLE Target ADD primary key(request_id);
向第一張表中批次插入資料
BEGIN
FOR i IN 1..100 LOOP
insert into Campaign select i, dbms_random.string('U', 10) from dual;
END LOOP;
COMMIT;
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
NULL;
END;
向雜湊分割槽表中批次插入資料
BEGIN
FOR k in (select compaign_id from Campaign order by 1) LOOP
FOR i IN 1..1000 LOOP
insert into Target select dbms_random.value(1,1000000),k.compaign_id from dual;
END LOOP;
END LOOP;
COMMIT;
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
NULL;
END;
檢視執行計劃
explain plan for select * from target where COMPAIGN_ID=70;
select * from table(dbms_xplan.display);
Plan hash value: 940899126
------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 4000 | 97K| 26 (0)| 00:00:01 | | |
| 1 | PARTITION HASH SINGLE| | 4000 | 97K| 26 (0)| 00:00:01 | 42 | 42 |
|* 2 | TABLE ACCESS FULL | TARGET | 4000 | 97K| 26 (0)| 00:00:01 | 42 | 42 |
------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("COMPAIGN_ID"=70)
建立LIST分割槽表,外來鍵引用上面建立的表
CREATE TABLE Target2(request_id number,compaign_id number,
CONSTRAINT compaign_id_fk2
FOREIGN KEY (compaign_id) REFERENCES Campaign(compaign_id))
PARTITION BY LIST(compaign_id)
( PARTITION p_default VALUES (DEFAULT));
ALTER TABLE Target2 ADD primary key(request_id);
向LIST分割槽表中批次插入資料
BEGIN
FOR k in (select compaign_id from Campaign order by 1) LOOP
FOR i IN 1..1000 LOOP
insert into Target2 select dbms_random.value(1,1000000),k.compaign_id from dual;
END LOOP;
END LOOP;
COMMIT;
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
NULL;
END;
將LIST分割槽拆分,將1、50拆分成兩個單獨的分割槽
ALTER TABLE Target2 SPLIT PARTITION p_default
VALUES (1)
INTO (PARTITION p_1, PARTITION p_default);
ALTER TABLE Target2 SPLIT PARTITION p_default
VALUES (50)
INTO (PARTITION p_50, PARTITION p_default);
select count(*) from target2 partition(p_default);
檢視執行計劃
explain plan for select * from target2 where COMPAIGN_ID=50;
select * from table(dbms_xplan.display);
Plan hash value: 1725981576
-------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
-------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 5000 | 122K| 10 (0)| 00:00:01 | | |
| 1 | PARTITION LIST SINGLE| | 5000 | 122K| 10 (0)| 00:00:01 | KEY | KEY |
| 2 | TABLE ACCESS FULL | TARGET2 | 5000 | 122K| 10 (0)| 00:00:01 | 2 | 2 |
-------------------------------------------------------------------------------------------------
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-2125321/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle hash partition雜湊分割槽(一)Oracle
- oracle hash partition雜湊分割槽(二)_操作限制Oracle
- 第41期:MySQL 雜湊分割槽表MySql
- oracle partition分割槽_分割槽列為空測試(一)Oracle
- 測試oracle子分割槽維護Oracle
- oracle list partition列表分割槽(一)Oracle
- oracle 11g 分割槽表Oracle
- MySQL LIST分割槽MySql
- oracle分割槽表的分類及測試Oracle
- ORACLE 11G分割槽表新功能:列表--範圍分割槽Oracle
- oracle 並行cpu查詢分割槽表測試Oracle並行
- [引用分割槽表]Oracle 11g新特性之引用分割槽表Oracle
- ORACLE 11g 範圍分割槽錶轉換INTERVAL分割槽表Oracle
- mysql 8.0.17 分割槽特性測試MySql
- 表分割槽機制測試
- Oracle分割槽表基礎運維-07增加分割槽(5RANGE_LIST)Oracle運維
- 全面學習分割槽表及分割槽索引(12)--修改list表分割槽索引
- oracle 測試 清除分割槽資料,索引釋放空間Oracle索引
- MySQL的List分割槽表MySql
- oracle組合分割槽系列三(composite list partition)Oracle
- HStreamDB v0.7 釋出:透明分割槽、雜湊演算法,多項效能提升新嘗試演算法
- Oracle 11g 分割槽拆分與合併Oracle
- 【ORACLE新特性】11G 分割槽新特性Oracle
- [間隔分割槽]Oracle10g、11g建立間隔分割槽表Oracle
- Hash分割槽表分割槽數與資料分佈的測試
- 深入解析partition-list 分割槽
- 全面學習分割槽表及分割槽索引(6)--建立range-list組合分割槽索引
- 使用Oracle Database 11g建立Interval分割槽表OracleDatabase
- Oracle 11g的新特性分割槽:System PartitionOracle
- 建立oracle10g 11g分割槽表Oracle
- oracle交換分割槽所引起的索引失效問題探究測試Oracle索引
- Oracle資料庫表範圍分割槽策略測試過程Oracle資料庫
- Oracle分割槽表及分割槽索引Oracle索引
- oracle 分割槽Oracle
- 簡單ORACLE分割槽表、分割槽索引Oracle索引
- oracle分割槽表和分割槽表exchangeOracle
- mysql~關於mysql分割槽表的測試MySql
- Oracle 表分割槽Oracle