首页 > Linux操作系统 > Linux操作系统 > 利用并行提高sql执行效率(转)
| 系统一共有4个CPU 首先打开session的并行 ALTER SESSION ENABLE PARALLEL DML; 创建一个测试表并带上并行属性,测试表记录数7541292 create table test_tableA tablespace TBS_DATA PARALLEL as select * from tableA; 此时表的属性是并行的,DML操作也将进行并行 及当前对该表的DML操作,即使不带上PARALLEL的hint也默认并行执行的 修改表的属性为NOPARALLEL alter table test_tableA NOPARALLEL; 执行下面的语句,检查session并没有多个并发进程 insert into test_tableA select * from tableA; 执行带并行的hint,可以在session看到有4个并发进程 insert /*+ PARALLEL(test_tableA) */ into test_tableA select * from tableA; --Executed in 109.448 seconds commit; 普通方式delete全表数据 delete test_tableA; --Executed in 236.4 seconds commit; select部分也带上并行hint,虽然并行度还是4,但执行效率更高 insert /*+ PARALLEL(test_tableA) */ into test_tableA select /*+ PARALLEL(tableA) */ * from tableA; --Executed in 28.351 seconds commit; 并行delete效率也比普通的要高不少 delete /*+ PARALLEL(test_tableA) */ test_tableA; --Executed in 144.648 seconds commit; |
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/241379/viewspace-714463/ ,如需转载,请注明出处,否则将追究法律责任。