05.11.2015 Views

Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

586<br />

CHAPTER 13 ■ PARTITIONING<br />

ops$tkyte@ORA10G> select * from table(dbms_xplan.display);<br />

PLAN_TABLE_OUTPUT<br />

----------------------------------------------------------------------------------<br />

| Operation | Name | Rows | Pstart| Pstop |<br />

----------------------------------------------------------------------------------<br />

| SELECT STATEMENT | | 1 | | |<br />

| PARTITION RANGE SINGLE | | 1 | 1 | 1 |<br />

| TABLE ACCESS BY LOCAL INDEX ROWID| PARTITIONED_TABLE | 1 | 1 | 1 |<br />

| INDEX RANGE SCAN | LOCAL_PREFIXED | 1 | 1 | 1 |<br />

----------------------------------------------------------------------------------<br />

Predicate Information (identified by operation id):<br />

---------------------------------------------------<br />

3 - access("A"=1 AND "B"=1)<br />

■Note The DBMS_XPLAN output has been edited to remove information that was not relevant, in order to<br />

permit the examples to fit on the printed page.<br />

So, the query that uses LOCAL_PREFIXED succeeds. The optimizer was able to exclude<br />

PART_2 of LOCAL_PREFIXED from consideration because we specified A=1 in the query, <strong>and</strong> we<br />

can see clearly in the plan that PSTART <strong>and</strong> PSTOP are both equal to 1. Partition elimination<br />

kicked in for us. The second query fails, however:<br />

ops$tkyte@ORA10G> select * from partitioned_table where b = 1;<br />

ERROR:<br />

ORA-00376: file 13 cannot be read at this time<br />

ORA-01110: data file 13: '/home/ora10g/.../o1_mf_p2_1dzn8jwp_.dbf'<br />

no rows selected<br />

And using the same technique, we can see why:<br />

ops$tkyte@ORA10G> delete from plan_table;<br />

4 rows deleted.<br />

ops$tkyte@ORA10G> explain plan for<br />

2 select * from partitioned_table where b = 1;<br />

Explained.<br />

ops$tkyte@ORA10G> select * from table(dbms_xplan.display);<br />

PLAN_TABLE_OUTPUT<br />

----------------------------------------------------------------------------------<br />

| Operation | Name | Rows | Pstart| Pstop |<br />

----------------------------------------------------------------------------------

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!