我正在执行成功执行的直接路径插入。当我尝试自动跟踪执行时,我得到了ORA-12838: cannot read/modify an object after modifying it in parallel
.
SQL> insert into emp_big select * from emp_big_temp;
411843 rows created.
Elapsed: 00:00:00.89
Execution Plan
----------------------------------------------------------
Plan hash value: 3203427748
-----------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------
| 0 | INSERT STATEMENT | | 357K| 45M| 1164 (1)| 00:00:14 |
| 1 | LOAD TABLE CONVENTIONAL | EMP_BIG | | | | |
| 2 | TABLE ACCESS FULL | EMP_BIG_TEMP | 357K| 45M| 1164 (1)| 00:00:14 |
-----------------------------------------------------------------------------------------
Note
-----
- dynamic sampling used for this statement (level=2)
Statistics
----------------------------------------------------------
15 recursive calls
31909 db block gets
12829 consistent gets
0 physical reads
34685216 redo size
845 bytes sent via SQL*Net to client
802 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
411843 rows processed
SQL> rollback;
Rollback complete.
Elapsed: 00:00:00.18
SQL>
SQL> insert /*+ append */ into emp_big select * from emp_big_temp;
411843 rows created.
Elapsed: 00:00:00.18
Execution Plan
----------------------------------------------------------
ERROR:
ORA-12838: cannot read/modify an object after modifying it in parallel
SP2-0612: Error generating AUTOTRACE EXPLAIN report
Statistics
----------------------------------------------------------
0 recursive calls
4438 db block gets
4283 consistent gets
0 physical reads
7648 redo size
829 bytes sent via SQL*Net to client
816 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
411843 rows processed
问题:
- 根据 ,表
emp_big
的并行度设置为 1select table_name, degree from user_tables
。为什么 Oracle 强制并行插入? - 为什么使用
autotrace trace
原因ORA-12838
?
对原始输出的回答:
这不是由自动跟踪引起的。即使没有自动跟踪,您也会遇到同样的错误,只需重复相同的直接路径插入即可。在第一次插入后发出提交。
这是记录在案的限制:ORA-12700 到 ORA-19400
编辑后对新输出的回答:
好的,所以你有一个回滚,你开始了一个新的事务。在这种情况下,autotrace 确实是间接的罪魁祸首。上面的规则仍然适用,正如上面的描述所说,即使是读取引用也会导致上面的错误。如果启用了自动跟踪,它会隐式运行如下内容(在您的原始语句完成后):
EXPLAIN PLAN SET STATEMENT_ID='PLUSxxxxxx' FOR insert /*+ append */ into emp_big select * from emp_big_temp;
您可以通过为错误 12838 启用 errorstack 跟踪来轻松确认这一点(对于这个简短的演示,在沙箱环境中没问题,但这不是我在真实数据库上执行此操作的方式):
alter system set events '12838 trace name errorstack level 3';
如果我现在运行它:
我会在警报日志中找到错误和跟踪文件。跟踪文件包含以下内容:
这就是导致错误的原因,因为它仍然是同一个事务。即使没有自动跟踪,您也可以测试它: