Oracle uses parallel pitfalls, and Oracle uses parallel

Source: Internet
Author: User

Oracle uses parallel pitfalls, and Oracle uses parallel

How can we quickly delete tens of millions of data records from tables with 10 million data records? You cannot directly delete the file. The best method is:

1. Use create table

2. Concurrent primary key and index creation

The problem is that the operation was performed the night before, and a very serious performance problem was found at work the next day. What is the problem? Let's create an experiment!

SQL> create table test as select * from dba_objects where object_id is not null;
SQL> alter table test add constraint pk_t_object_id primary key (object_id) parallel 16 nologging;
SQL> create index idx_t_object_name on test (object_name) parallel 16 nologging;
SQL> select s. table_name, s. degree
From user_tables s
Where s. table_name = 'test ';
TABLE_NAME DEGREE
-----------------------------------------------
TEST 16

SQL> select s. index_name, s. degree
From user_indexes s
Where s. table_name = 'test ';
INDEX_NAME DEGREE
-----------------------------------------------
PK_T_OBJECT_ID 1
IDX_T_OBJECT_NAME 16

There are two pitfalls: 1. Check whether the degree of parallelism in the table has changed. 2. Has the degree of parallelism in the index changed?

You need to return the degree of parallelism.

SQL> alter table test noparallel;
SQL> alter index idx_t_object_name noparallel;
SQL> select s. table_name, s. degree
From user_tables s
Where s. table_name = 'test ';
TABLE_NAME DEGREE
--------------------------------------------------
TEST 1
SQL> select s. index_name, s. degree
From user_indexes s
Where s. table_name = 'test ';
INDEX_NAME DEGREE
---------------------------------------------------
PK_T_OBJECT_ID 1
IDX_T_OBJECT_NAME 1

When the degree of parallelism is used, a SQL statement is executed on only one CPU without the degree of parallelism. If parallel execution is added, it will be executed on multiple CPUs, and a large number of concurrent execution will inevitably lead to Contention. In the database report, there will be db file parallel read wait events.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.