Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

about Oracle parallel insert performance

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!

like image 528
Gary Avatar asked May 02 '12 21:05

Gary


People also ask

Can we use parallel hint in INSERT statement in Oracle?

In the INSERT ... SELECT statement, you can specify a PARALLEL hint after the INSERT keyword, in addition to the hint after the SELECT keyword. The PARALLEL hint after the INSERT keyword applies to the INSERT operation only, and the PARALLEL hint after the SELECT keyword applies to the SELECT operation only.

What is INSERT parallel?

The parallel INSERT feature significantly improves the performance of individual INSERT statements adding to the innovative and powerful technology of BLU Acceleration. In a partitioned database system (DPF), there is already some parallelization at the database partition level even with the feature disabled.

How does parallel processing work in Oracle?

Introduction to Parallel Execution. When Oracle runs SQL statements in parallel, multiple processes work together simultaneously to run a single SQL statement. By dividing the work necessary to run a statement among multiple processes, Oracle can run the statement more quickly than if only a single process ran it.

What is Nologging parallel in Oracle?

NOLOGGING means that no redo log is generated for the operation. NOLOGGING is never the default; use it when you want to optimize performance. It should not normally be used when recovery is needed for the table or partition.


Video Answer


2 Answers

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;
  1. You always want to enable parallel dml first.
  2. 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.
  3. 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.
like image 90
Jon Heller Avatar answered Oct 16 '22 02:10

Jon Heller


You do not need DBA privileges to run an explain plan. I believe that SELECT_CATALOG is the correct privilege.

like image 31
David Aldridge Avatar answered Oct 16 '22 02:10

David Aldridge