PARALLEL并行操作
语法:/+parallel(table_short_name,cash_number)/
使用前我们需要看我们的电脑有几个cpu,并且每个cpu能够并行的线程数
查看Oracle能利用的最大并行度
SQL> show parameters cpu
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cpu_count integer 80
parallel_threads_per_cpu integer 2
resource_manager_cpu_allocation integer 80
1.cpu_count表示cpu数
2.parallel_threads_per_cpu表示每个cpu允许的并行进程数
3.default情况下,并行数为cpu_count*parallel_threads_per_cpu
具体使用
下面展示一些 具体示例
。
//没用并行操作
select count(*)
from user_tables t
left join user_tab_comments v
on t.TABLE_NAME = v.TABLE_NAME
where Length(comments)<>8
order by num_rows desc;
//用并行操作
select /*+parallel(t,32)(v,32)*/ count(*) --多表示例
from user_tables t
left join user_tab_comments v
on t.TABLE_NAME = v.TABLE_NAME
where Length(comments)<>5
order by num_rows desc;