操作内并行使用的slave process数量就是并行度dop,indextable都有dop 作为默认操作并行度default 1表示不使用并行处理 SQL create table t1 (a int) parallel 6; Table created. SQL select degree from user_tables where table_name=’T1′; DEGREE ——
操作内并行使用的slave process数量就是并行度dop,index&table都有dop 作为默认操作并行度default 1表示不使用并行处理
SQL> create table t1 (a int) parallel 6;
Table created.
SQL> select degree from user_tables where table_name=’T1′;
DEGREE
———-
6
SQL> alter table t1 parallel 3;
Table altered.
SQL> select degree from user_tables where table_name=’T1′;
DEGREE
———-
3
*禁用alter table(index) parallel 1 (noprallel)
#create 时候使用parallel不仅会在创建table&index时使,后续的操作ddl,dml也会使用(如果只想建表时使用,建好后修改)
SQL> create table t2 (a int) parallel;(未指定并行度)
Table created.
SQL> select degree from user_tables where table_name=’T2′;
DEGREE
———-
DEFAULT ~~~这样使用default并行度=(cpu_count*parallel_threads_per_cpu)
SQL> show parameter cpu_count
NAME TYPE VALUE
———————————— ———– ——————————
cpu_count integer 2
SQL> show parameter parallel_thread
NAME TYPE VALUE
———————————— ———– ——————————
parallel_threads_per_cpu integer 2
SQL>
SQL> insert into t2 values (1);
1 row created.
SQL> commit;
Commit complete.
SQL> set autotrace trace exp
SQL> select * from t2;
Execution Plan
———————————————————-
Plan hash value: 1216610266
——————————————————————————–
——————————
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time
| TQ |IN-OUT| PQ Distrib |
——————————————————————————–
——————————
| 0 | SELECT STATEMENT | | 1 | 13 | 2 (0)| 00:00:01
| | | |
| 1 | PX COORDINATOR | | | | |
| | | |
| 2 | PX SEND QC (RANDOM)| :TQ10000 | 1 | 13 | 2 (0)| 00:00:01
| Q1,00 | P->S | QC (RAND) |
| 3 | PX BLOCK ITERATOR | | 1 | 13 | 2 (0)| 00:00:01
| Q1,00 | PCWC | |
| 4 | TABLE ACCESS FULL| T2 | 1 | 13 | 2 (0)| 00:00:01
| Q1,00 | PCWP | |
——————————————————————————–
——————————
Note
—–
– dynamic sampling used for this statement
SQL>
SQL> set autotrace off
SQL> select process from v$pq_tqstat;
no rows selected
可以看到 用set autotrace 后 查v$pq_tqstat norows ,这是2个原因造成的
1.set autotrace的原理
开启autotrace时候 一个process对应 2个 session
通常情况下是一个 session对应一个 server processs,但SErVER PORCESSS 可以对应多个session
SQL> conn xh/a831115
已连接。
SQL> select distinct sid from v$mystat;
SID
———-
144
SQL> select username, sid, serial#, server, paddr, status from v$session where s
id=144;
USERNAME SID SERIAL# SERVER PADDR STATUS
—————————— ———- ———- ——— ——– ——–
XH 144 27 DEDICATED 20E4CC3C INACTIVE
SQL> select program ,addr from v$process where addr=(select paddr from v$session
where sid=144);
PROGRAM ADDR
—————————————————————- ——–
ORACLE.EXE (SHAD) 20E4CC3C
SQL> select sid from v$session where paddr=’20E4CC3C’;
SID
———-
144
SQL> set autotrace on
SQL> select sid from v$session where paddr=’20E4CC3C’;
SID
———-
144
154
2.v$pq_tqstat只提供当前session最后一次并行执行sql语句的信息
综合2点可以看出set autotrace 最后一个session 是 执行计划的,所以v$pq_tqstat为no rows
所以 直接执行
SQL> select * from t2;
A
———-
1
SQL> SELECT dfo_number, tq_id, server_type, process, num_rows, bytes
2 FROM v$pq_tqstat
3 ORDER BY dfo_number, tq_id, server_type DESC, process;
DFO_NUMBER TQ_ID SERVER_TYP PROCESS NUM_ROWS BYTES
———- ———- ———- ———- ———- ———-
1 0 Producer P000 1 24
1 0 Producer P001 0 20
1 0 Producer P002 0 20
1 0 Producer P003 0 20
1 0 Consumer QC 1 84
可以看到启动了4个slave process,这4个process=cpu_count*parallel_threads_per_cpu(2*2)
相关的hint:
parallel(10g,11g),no_parallel(10g,11g),parallel_index(10g,11g,9i),no_parallel_index(10g,11g)
noparallel(9i),noparallel_index(9i)
##需要知道并行hint只是告诉优化器可以使用并行,但不是强制使用并行一切还是从cost出发(重点)
declare
begin
for i in 1..1000 loop
insert into t2 values(i);
end loop;
commit;
end;
SQL> explain plan set statement_id=’t2_pp’ for select /*+parallel(t2 2)*/* from t2 where a>900;
Explained.
SQL> create index t2_id on t2 (a);
Index created.
SQL> explain plan set statement_id=’t2_id’ for select /*+parallel(t2 2)*/* from t2 where a>900;
Explained.
SQL> set linesize 1000
SQL> select * from table (dbms_xplan.display(null,’t2_pp’));
PLAN_TABLE_OUTPUT
————————————————————————————————————————————————————————————————————————————————————————————————————
Plan hash value: 1216610266
————————————————————————————————————–
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | TQ |IN-OUT| PQ Distrib |
————————————————————————————————————–
| 0 | SELECT STATEMENT | | 100 | 1300 | 2 (0)| 00:00:01 | | | |
| 1 | PX COORDINATOR | | | | | | | | |
| 2 | PX SEND QC (RANDOM)| :TQ10000 | 100 | 1300 | 2 (0)| 00:00:01 | Q1,00 | P->S | QC (RAND) |
| 3 | PX BLOCK ITERATOR | | 100 | 1300 | 2 (0)| 00:00:01 | Q1,00 | PCWC | |
|* 4 | TABLE ACCESS FULL| T2 | 100 | 1300 | 2 (0)| 00:00:01 | Q1,00 | PCWP | |
————————————————————————————————————–
PLAN_TABLE_OUTPUT
————————————————————————————————————————————————————————————————————————————————————————————————————
Predicate Information (identified by operation id):
—————————————————
4 – filter(“A”>900)
Note
—–
– dynamic sampling used for this statement
20 rows selected.
SQL> select * from table (dbms_xplan.display(null,’t2_id’));
PLAN_TABLE_OUTPUT
————————————————————————————————————————————————————————————————————————————————————————————————————
Plan hash value: 523330294
————————————————————————–
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
————————————————————————–
| 0 | SELECT STATEMENT | | 100 | 1300 | 2 (0)| 00:00:01 |
|* 1 | INDEX RANGE SCAN| T2_ID | 100 | 1300 | 2 (0)| 00:00:01 |
————————————————————————–
Predicate Information (identified by operation id):
—————————————————
PLAN_TABLE_OUTPUT
————————————————————————————————————————————————————————————————————————————————————————————————————
1 – access(“A”>900)
Note
—–
– dynamic sampling used for this statement
17 rows selected.
可以看到 即使在使用并行与走index时cost一样时候还是选择了走index(cost表面一样,若使用trace alter session set events ’10053 trace name context forever’;看的更详细,并行cpu cost要高些,所以选择了走index,所以hint parallel,parallel_index只是告诉query optimizer
可以考虑并行 不是强制使用)

oracle asm指的是“自动存储管理”,是一种卷管理器,可自动管理磁盘组并提供有效的数据冗余功能;它是做为单独的Oracle实例实施和部署。asm的优势:1、配置简单、可最大化推动数据库合并的存储资源利用;2、支持BIGFILE文件等。

方法:1、利用“select*from user_indexes where table_name=表名”语句查询表中索引;2、利用“select*from all_indexes where table_name=表名”语句查询所有索引。

在Oracle中,可利用lsnrctl命令查询端口号,该命令是Oracle的监听命令;在启动、关闭或重启oracle监听器之前可使用该命令检查oracle监听器的状态,语法为“lsnrctl status”,结果PORT后的内容就是端口号。

在oracle中,可以利用“TO_SINGLE_BYTE(String)”将全角转换为半角;“TO_SINGLE_BYTE”函数可以将参数中所有多字节字符都替换为等价的单字节字符,只有当数据库字符集同时包含多字节和单字节字符的时候有效。

在oracle中,可以利用“drop sequence sequence名”来删除sequence;sequence是自动增加数字序列的意思,也就是序列号,序列号自动增加不能重置,因此需要利用drop sequence语句来删除序列。

在oracle中,可以利用“select ... From all_tab_columns where table_name=upper('表名') AND owner=upper('数据库登录用户名');”语句查询数据库表的数据类型。

方法:1、利用“LOWER(字段值)”将字段转为小写,或者利用“UPPER(字段值)”将字段转为大写;2、利用“REGEXP_LIKE(字符串,正则表达式,'i')”,当参数设置为“i”时,说明进行匹配不区分大小写。

方法:1、利用“alter system set sessions=修改后的数值 scope=spfile”语句修改session参数;2、修改参数之后利用“shutdown immediate – startup”语句重启服务器即可生效。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Linux new version
SublimeText3 Linux latest version

Notepad++7.3.1
Easy-to-use and free code editor

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6
Visual web development tools
