A reader, December 19, 2002 - 10:56 am UTC
Hi Tom
I heard that histogram is obsolite after oracle 8i.
Is it true?
Thanks,
December 19, 2002 - 11:28 am UTC
patently FALSE.
Only the explain plan
Raghu, December 19, 2002 - 1:00 pm UTC
Thanks Tom. That confirms what I guessed at. Also, when I do a "set autotr trace explain" and issue a statement, should it not just give me the explain plan without executing the sql itself? In my case it went ahead and deleted the rows (which took more time). What's the exact command for just getting the explain plan?
December 19, 2002 - 1:09 pm UTC
set autotrace traceonly explain
will just explain a SELECT, since actually executing the select won't have any effect (you see no rows, you see no stats).
but for DELETE (or insert/update/merge) it runs the command because NOT executing it does have a side effect.
To just see the plan:
scott@ORA920> delete from plan_table;
0 rows deleted.
scott@ORA920> explain plan for delete from emp;
Explained.
scott@ORA920> @?/rdbms/admin/utlxpls
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
--------------------------------------------------------------------
| 0 | DELETE STATEMENT | | | | |
| 1 | DELETE | EMP | | | |
| 2 | TABLE ACCESS FULL | EMP | | | |
--------------------------------------------------------------------
Note: rule based optimization
10 rows selected.
scott@ORA920> delete from plan_table;
3 rows deleted.
Confusing Explain plan
Arul, May 14, 2004 - 4:45 am UTC
1. In below example why there is no table access clause
SQL> delete from emp where empno=12;
0 rows deleted.
Execution Plan
----------------------------------------------------------
0 DELETE STATEMENT Optimizer=CHOOSE
1 0 DELETE OF 'EMP'
2 1 INDEX (UNIQUE SCAN) OF 'PK_EMP' (UNIQUE)
2. I did following tests across version which are more intersting. Why only explain plan for Test 1 is similar and why it differs in Test 2 and 3.
Oracle8i Enterprise Edition Release 8.1.7.4.1 - Production
----------------------------------------------------------
1. SQL> delete from emp where empno=12;
0 rows deleted.
Execution Plan
----------------------------------------------------------
0 DELETE STATEMENT Optimizer=CHOOSE
1 0 DELETE OF 'EMP'
2 1 INDEX (UNIQUE SCAN) OF 'PK_EMP' (UNIQUE)
SQL>
SQL> create index index1 on emp(ename);
Index created.
SQL> create index index2 on emp(sal);
Index created.
2. SQL> delete from emp where ename='ADAM';
0 rows deleted.
Execution Plan
----------------------------------------------------------
0 DELETE STATEMENT Optimizer=CHOOSE
1 0 DELETE OF 'EMP'
2 1 TABLE ACCESS (BY INDEX ROWID) OF 'EMP'
3 2 INDEX (RANGE SCAN) OF 'INDEX1' (NON-UNIQUE)
3. SQL> delete from emp where sal=12;
0 rows deleted.
Execution Plan
----------------------------------------------------------
0 DELETE STATEMENT Optimizer=CHOOSE
1 0 DELETE OF 'EMP'
2 1 TABLE ACCESS (BY INDEX ROWID) OF 'EMP'
3 2 INDEX (RANGE SCAN) OF 'INDEX2' (NON-UNIQUE)
SQL>
Oracle9i Enterprise Edition Release 9.2.0.5.0 - Production
----------------------------------------------------------
1. SQL> delete from emp where empno=12;
0 rows deleted.
Execution Plan
----------------------------------------------------------
0 DELETE STATEMENT Optimizer=CHOOSE
1 0 DELETE OF 'EMP'
2 1 INDEX (UNIQUE SCAN) OF 'PK_EMP' (UNIQUE)
SQL>
SQL> create index index1 on emp(ename);
Index created.
SQL> create index index2 on emp(sal);
Index created.
2. SQL> delete from emp where ename='ADAM';
0 rows deleted.
Execution Plan
----------------------------------------------------------
0 DELETE STATEMENT Optimizer=CHOOSE
1 0 DELETE OF 'EMP'
2 1 INDEX (RANGE SCAN) OF 'INDEX1' (NON-UNIQUE)
3. SQL> delete from emp where sal=12;
0 rows deleted.
Execution Plan
----------------------------------------------------------
0 DELETE STATEMENT Optimizer=CHOOSE
1 0 DELETE OF 'EMP'
2 1 INDEX (RANGE SCAN) OF 'INDEX2' (NON-UNIQUE)
Thanx in Advance.
May 14, 2004 - 10:23 am UTC
i would ignore this, delete of 'emp' is a table access. just a nuance of explain plan, nothing to worry about.
Why its not similar within the version 8174 ?
Arul, May 15, 2004 - 10:53 pm UTC
Hi,
I am still confused about the variation in explain plan. I agree for the 3 similar plans in 9205. But why in 8174 for last 2 deletes the plans is diffrent from first delete.
Why "TABLE ACCESS (BY INDEX ROWID) OF 'EMP'" access path is not shown in "SQL> delete from emp where empno=12;" for 8174 where as the other deletes in 8174 has this access path. Any technical explanation for the variations within the same version. ?
"TABLE ACCESS (BY INDEX ROWID) OF 'EMP'"
May 16, 2004 - 10:23 am UTC
don't worry about it. just a nuance, the delete obviously accesses the table.
if you want to dig into it and find the code that is causing it, you can work it via support. I don't really dig into the source code and as it has no material affect on *anything*....