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:
alter session enable parallel dml;
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 the append
hint can make a big difference. (This suggestion to use the append
hint assumes you only care about maximum performance. If you can't use direct-path writes, perhaps because you need the table to be immediately recoverable or modifiable during the insert, then you may want to avoid the append
hint or even use noappend
.)