使用bulkCollect解決資料遷移問題
機器配置:IBM P690 6U12G
資料庫版本: Oracle 9.2.0.6
需求: 根據主外來鍵關係遷移tb1446表內資料至tb1446_copy
表tb1446內有20個Hash分割槽,根據分割槽結合bulk collect技術,一次提交25000條記錄(需要測試後得出一次提交的記錄數),使得整個單表遷移過程耗時最短.
[@more@]SQL> select count(*) from ecifupdate.tb1446;
COUNT(*)
----------
7087611
SQL> select count(*) from ecifupdate.tb1560;
COUNT(*)
----------
74735643
編寫bulk collect方式的儲存過程.
migration_tb1446_part_00
migration_tb1446_part_01
migration_tb1446_part_02
migration_tb1446_part_03
.
.
.
migration_tb1446_part_19
給個sample參考(待完善)
create or replace procedure migration_tb1446_part_00
is
type tb_bulk_type is table of tb1446_copy%rowtype;
ref_bulk tb_bulk_type;
Cursor c_bulk is
select a.*
from ecifupdate.tb1446 partition(part_00) a,
ecifupdate.tb1560 b
where a.arrangement_id = b.linkedarrangement;
begin
open c_bulk;
loop
fetch c_bulk bulk collect into ref_bulk limit 25000;
forall i in 1 .. ref_bulk.count
insert into tb1446_copy values ref_bulk(i);
exit when c_bulk%notfound;
end loop;
close c_bulk;
end;
單個程式執行一個hash分割槽的耗時是00:01:16.68
SQL> exec migration_tb1446_part_00;
PL/SQL procedure successfully completed.
Elapsed: 00:01:16.68
考慮資源配置(cpu,i/o)可以採用並行方式處理.
我這裡四個程式並行處理20個分割槽總共耗時7分17秒完成.
遷移後tb1446_copy表記錄數
SQL> select count(*) from tb1446_copy;
COUNT(*)
----------
2890208
這裡要說明一點:
a.arrangement_id = b.linkedarrangement必須是主外來鍵連線才能保證tb1446_copy表內沒有重複資料.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/76065/viewspace-873617/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 使用資料泵遷移遇到的問題
- 教程:使用遷移學習來解決影像問題!遷移學習
- Laravel5的資料庫表建立問題 資料庫遷移操作報錯問題解決Laravel資料庫
- 遷移資料庫資料考慮問題資料庫
- 解決mysql8.0.13dm7資料遷移相關問題undefinedMySqlUndefined
- 資料遷移部分問題總結
- 利用sqlldr工具進行資料遷移時發現的問題解決方法SQL
- 【遷移】使用rman遷移資料庫資料庫
- 兩款工具解決SQL Server遷移問題DJSQLServer
- 解決Oracle資料庫遷移後的伺服器負載效能問題JSOracle資料庫伺服器負載JS
- 資料遷移中需要考慮的問題
- 【資料遷移】使用傳輸表空間遷移資料
- SQL SERVER 資料庫遷移孤立使用者的解決方法SQLServer資料庫
- 大資料量資料遷移後統計資訊問題大資料
- fastdfs資料遷移以及fastdfs問題排查記錄AST
- Laravel 5.5 資料遷移問題:Specified key was too longLaravel
- GoldenGate資料遷移的問題總結(一)Go
- GoldenGate資料遷移的問題總結(二)Go
- 資料遷移中的幾個問題總結
- 生產環境資料遷移問題彙總
- WebSphere客戶端遷移的常見問題解決二Web客戶端
- 使用RMAN進行資料遷移
- 使用expdp、impdp遷移資料庫資料庫
- 使用prebuilt table 方式遷移資料UI
- 新舊系統更替產生的資料遷移問題
- 資料遷移(MYSQL--ORACLE)中碰到的亂碼問題MySqlOracle
- 遷移資料.
- 解決遷移資料庫錯誤,索引長度過長資料庫索引
- 【DATAPUMP】使用DataPump遷移Oracle資料庫Oracle資料庫
- 解決svn遷移過程中出現:SVN Error: is not the same repository as的問題Error
- X7一體機資料庫遷移問題處理資料庫
- max_allowed_packet引起MySQL遷移丟失資料的問題MySql
- 聊聊國產資料庫遷移中的表連線效能問題資料庫
- 海量資料遷移之一個誤操作的問題總結
- 關於Oracle資料庫中行遷移/行連結的問題Oracle資料庫
- 通過impdp做資料庫遷移遇到的問題總結資料庫
- 使用資料泵(expdp、impdp)遷移資料庫流程資料庫
- 解決AI的小資料問題AI