[Oracle Notes]About Oracle parallel insert performance-有关oracle并行插入性能
Question:
I have an sql like this:
Insert into A
Select * from B;
Now I want it to run in parallel. My question is to parallelize the insert or select or both? See the following sqls, can you tell me which one is correct or which one has best performance. I don't have dba permission, so I cann't check its execute plan.
1) Insert /*+ parallel(A 6) */ into A select * from B;
2) Insert into A select/*+ parallel(B 6) */ * from B;
3) Insert /*+ parallel(A 6) */ into A select /*+ parallel(B 6) */ * from B;
Thank you!
Answer:
Parallelizing both the INSERT
and the SELECT
is the fastest.
(If you have a large enough amount of data, you have a decent server, everything is configured sanely, etc.)
You'll definitely want to test it yourself, especially to find the optimal degree of parallelism. There are a lot of myths surrounding Oracle parallel execution, and even the manual is sometimes horribly wrong.
On 11gR2, I would recommend you run your statement like this:
SQL> set timing on
SQL> alter session enable parallel dml;
SQL> insert/*+ append parallel(6) */into A select * from B;
- You always want to enable parallel dml first.
parallel(6)
uses statement-level parallelism, instead of object-level parallelism. This is an 11gR2 feature that allows you to easily run everything in parallel witout having to worry about object aliases or access methods. For 10G you'll have to use multiple hints.- Normally the
append
hint isn't necessary. If your DML runs in parallel, it will automatically use direct-path inserts. However, if your statement gets downgraded to serial, for example if there are no parallel servers available, then theappend
hint can make a big difference.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本