[转帖]ORACLE 并行(PARALLEL)实现方式及优先级

oracle,并行,parallel,实现,方式,优先级 · 浏览次数 : 0

小编点评

## Parallel Query Tutorial This document provides an overview of parallel query options in Oracle database, covering both default settings and manual overrides. **1. Default Parallel Settings** By default, Oracle database transactions are executed in a serial fashion. However, this can be changed to parallel execution with the `ALTER SESSION FORCE PARALLEL QUERY` statement. This allows multiple queries to be executed concurrently, significantly improving performance. **2. Parallel DML Operations** For **INSERT**, **UPDATE**, **DELETE**, and **MERGE** statements, the `ALTER SESSION FORCE PARALLEL DML` statement can be used to enable parallel execution. This allows data modifications to be applied concurrently, reducing overall execution time. **3. Parallel DDL Operations** While not applicable to all data types, the `ALTER SESSION FORCE PARALLEL DDL` statement can also be used to enable parallel execution for **CREATE**, **INDEX**, **TABLE**, and **ALTER TABLE** statements. This allows for concurrent execution of these operations, improving efficiency. **4. Parallel Session Restrictions** While enabling parallel execution for DML/DDL statements, it is important to consider the following restrictions: * **Parallel DML only applies to non-partitioned tables.** * **Parallel DDL is not supported for constraints, indexes, and other object types.** * **Setting a specific DOP (Degree of Parallelism) is still necessary for subsequent statements.** **5. Conclusion** Understanding parallel query options in Oracle is crucial for optimizing data processing. By carefully controlling session settings and using appropriate statements, you can achieve significant performance gains while maintaining data integrity and consistency.

正文

 

 

http://blog.itpub.net/25542870/viewspace-2120924/

 

一、      Parallel query

默认情况下session 是ENABLE状态

1.       实现方式

1 Alter session force parallel query;

2 Alter table tab1 parallel n;

3 Hist方式

2.       并行度设置

Alter table tab1 parallel n;

Select /*+parallel(tab n)*/ from tab;

Alter session force parallel query parallel n;

如果没有设置将执行默认并行度

3.       默认并行度

单实例 = PARALLEL_THREADS_PER_CPU x CPU_COUNT

RAC = PARALLEL_THREADS_PER_CPU x CPU_COUNT x INSTANCE_COUNT

SQL> show parameter parallel

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
fast_start_parallel_rollback string LOW
parallel_adaptive_multi_user boolean TRUE
parallel_automatic_tuning boolean FALSE
parallel_degree_limit string CPU
parallel_degree_policy string MANUAL
parallel_execution_message_size integer 16384
parallel_force_local boolean FALSE
parallel_instance_group string
parallel_io_cap_enabled boolean FALSE
parallel_max_servers integer 970
parallel_min_percent integer 0
parallel_min_servers integer 0
parallel_min_time_threshold string AUTO
parallel_server boolean FALSE
parallel_server_instances integer 1
parallel_servers_target integer 768
parallel_threads_per_cpu integer 2
recovery_parallelism integer 0

SQL> show parameter cpu

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cpu_count integer 48
parallel_threads_per_cpu integer 2
resource_manager_cpu_allocation integer 48

SQL> show parameter instance

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
active_instance_count integer
cluster_database_instances integer 1
instance_groups string
instance_name string cnups1u
instance_number integer 0
instance_type string RDBMS
open_links_per_instance integer 4
parallel_instance_group string
parallel_server_instances integer 1

新创建表默认并行度是1

SQL> create table tab_3 as select * from dba_objects;

 

Table created.

SQL> select table_name,degree from user_tables;

 

TABLE_NAME                     DEGREE

------------------------------ ----------

TAB_3                                   1

 

4.       优先级(并行度覆盖)

官方说明

If you are sure you want to execute in parallel and want to avoid setting the DOP for a table or modifying the queries involved, you can force parallelism with the following statement:

ALTER SESSION FORCE PARALLEL QUERY;

All subsequent queries are executed in parallel provided no restrictions are violated. You can also force DML and DDL statements. This clause overrides any parallel clause specified in subsequent statements in the session, but is overridden by a parallel hint.

In typical OLTP environments, for example, the tables are not set parallel, but nightly batch scripts may want to collect data from these tables in parallel. By setting the DOP in the session, the user avoids altering each table in parallel and then altering it back to serial when finished.

 

Hint > session > object

二、      Parallel DML (INSERT, UPDATE, DELETE, and MERGE) 

 

 

默认情况下session 是DISBALE状态

只有再使用(Alter session force parallel DML;

或者Alter session enable parallel DML)才可以使用parallel并行

1.       实现方式

Alter session force parallel DML;

Alter table tab1 parallel n;

Hist 方式

2.       并行度设置

Alter table tab1 parallel n;

Alter session force parallel DML parallel n;

UPDATE /*+ PARALLEL(tab1,4) */ tbl_2 SET c1=c1+1;

INSERT /*+ PARALLEL(tbl_ins,2) */ INTO tbl_ins

SELECT /*+ PARALLEL(tbl_sel,4) */ * FROM tbl_sel;

DELETE /*+ PARALLEL (t1, 2) */ FROM t1

如果没有设置将执行默认并行度

3.       优先级(并行度覆盖)

Hint > session > object

三、      Parallel DDL

支持的操作

非分区表

CREATE INDEX

CREATE TABLE ... AS SELECT

ALTER INDEX ... REBUILD

分区表

CREATE INDEX

CREATE TABLE ... AS SELECT

ALTER TABLE ... [MOVE|SPLIT|COALESCE] PARTITION

ALTER INDEX ... [REBUILD|SPLIT] PARTITION

 

默认情况下session 是ENABLE状态

1.       实现方式

ALTER SESSION FORCE PARALLEL DDL

PARALLEL clause

2.       优先级(并行度覆盖)

Hint > session

3.       并行度设置

ALTER SESSION FORCE PARALLEL DDL parallel 10;<span "="">

CREATE INDEX ….parallel 10;

ALTER INDEX ... REBUILD parallel 10;

ALTER INDEX ... MOVE PARTITION parallel 10;

ALTER INDEX ...SPLIT PARTITION parallel 10;

 

All for u
 

与[转帖]ORACLE 并行(PARALLEL)实现方式及优先级相似的内容:

[转帖]ORACLE 并行(PARALLEL)实现方式及优先级

http://blog.itpub.net/25542870/viewspace-2120924/ 一、 Parallel query 默认情况下session 是ENABLE状态 1. 实现方式 1 Alter session force parallel query; 2 Alter table

[转帖]Python连接Oracle数据库进行数据处理操作

https://www.dgrt.cn/a/2259443.html?action=onClick 解决以下问题: Python连接Oracle数据库,并查询、提取Oracle数据库中数据? 通过Python在Oracle数据库中创建表 Python数据插入到Oracle数据库中? Python删除

[转帖]KingbaseES和Oracle数据类型的映射表

随着数据库国产化的进程,Oracle向KingbaseES数据库的数据迁移需求也越来越多。数据库之间数据迁移的时候,首先遇到的,并且也是最重要的,就是数据类型之间的转换。 下表为KingbaseES和Oracle数据类型的映射表: Oracle数据类型 KingbaseES 数据类型 备注说明(Or

[转帖]并发delete导致oracle死锁问题的解决

项目中有一个批处理任务,用来删除数据库中过期的数据(包括说话人的语音、模型、记录等),当程序被分布式部署后,就会有多个批处理线程同时进行删除,不过不同的线程,会根据元信息表得到不同的说话人信息,从而删除不同的数据,并不存在竞争的问题,但是,当项目使用oracle数据库在线上运行时,却频繁出现了ORA

[转帖]OS Watcher (OSW)系统性能监控软件

https://www.anbob.com/archives/1143.html OS Watcher简称OSW(oswbb),用于收集并归档操作系统cpu,memery,disk io,network等相关信息的工具,是oracle提供的脚本工具集,全是shell编写,OSW内部是使用操作系统提供

[转帖]IvorySQL

https://www.modb.pro/wiki/2713 简介:IvorySQL 是先进的、功能齐全的开源 兼容 Oracle的PostgreSQL数据库,并坚定地承诺始终保持 100% 兼容并直接替换最新的 PostgreSQL。IvorySQL 添加了一个“compatible_db”切换开

[转帖]create table INITRANS参数分析

https://www.modb.pro/db/44701 1. 内容介绍 Oracle数据库create table时使用INITRANS参数设置数据块ITL事务槽的数量,确保该数据块上 并发事务数量。参数内容总结如下, 1. Oracle 8K blocksize 数据块初始 2个itl,8K

[转帖]openGauss的WDR报告解读

文章目录 1.执行以下SQL命令,查询已经生成的快照信息。2.生成WDR报告。3.手工创建快照信息4.WDR涉及的数据表5.WDR报告解读 在Oralce数据库中,遇到性能问题,我们通常会查看有无对应时间段的快照,生成awr报告并进一步分析(AWR是Automatic Workload Reposi

[转帖]Oracle Linux 9 - Oracle 提供支持 RHEL 兼容发行版

https://sysin.org/blog/oracle-linux-9/ Oracle Linux 是一个开放、全面的操作环境,提供虚拟化、管理、云原生计算工具和操作系统,通过一个统一的支持解决方案满足您的业务需求。Oracle Linux 与 Red Hat Enterprise Linux

[转帖]Oracle数据库的两种授权收费方式详解

https://www.jb51.net/article/265823.htm 现在Oracle有两种授权收费方式,按CPU(Process)数和按用户数(Named User Plus),前一种方式一般用于用户数不确定或者用户数量很大的情况,典型的如互联网环境,这篇文章主要介绍了Oracle数据库