Discovering When an Index Is Useful : Index STATISTICS « Index « Oracle PL / SQL

Oracle PL / SQL
1. Aggregate Functions
2. Analytical Functions
3. Char Functions
4. Constraints
5. Conversion Functions
6. Cursor
7. Data Type
8. Date Timezone
9. Hierarchical Query
10. Index
11. Insert Delete Update
12. Large Objects
13. Numeric Math Functions
14. Object Oriented Database
15. PL SQL
16. Regular Expressions
17. Report Column Page
18. Result Set
19. Select Query
20. Sequence
21. SQL Plus
22. Stored Procedure Function
23. Subquery
24. System Packages
25. System Tables Views
26. Table
27. Table Joins
28. Trigger
29. User Previliege
30. View
31. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Oracle PL / SQL » Index » Index STATISTICS 
Discovering When an Index Is Useful
 
SQL>
SQL>
SQL> set autotrace off
SQL>
SQL> create table indextest as select from dba_objects
  2  where owner in ('OUTLN','PUBLIC','SCOTT','SYS','SYSTEM');

Table created.

SQL>
SQL>
SQL> select owner, count(*from indextest group by owner;

OWNER                            COUNT(*)
------------------------------ ----------
PUBLIC                               2767
OUTLN                                   8
SYSTEM                                449
SYS                                  6683

SQL>
SQL> create index indxtest_owner_idx on indextest (owner);

Index created.

SQL>
SQL> set autotrace trace explain
SQL>
SQL> select owner, object_name from indextest where owner='SYS';

Execution Plan
----------------------------------------------------------
Plan hash value: 2792531790

-------------------------------------------------------------------------------
| Id  | Operation         | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------
|   SELECT STATEMENT  |           |  7763 |   629K|    36   (3)00:00:01 |
|*  |  TABLE ACCESS FULL| INDEXTEST |  7763 |   629K|    36   (3)00:00:01 |
-------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   - filter("OWNER"='SYS')

Note
-----
   - dynamic sampling used for this statement

SQL>
SQL> select owner, object_name from indextest where owner='SCOTT';

Execution Plan
----------------------------------------------------------
Plan hash value: 3406603611

--------------------------------------------------------------------------------------------------
| Id  | Operation                   | Name               | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------------------
|   SELECT STATEMENT            |                    |     |    83 |     1   (0)00:00:01 |
|   |  TABLE ACCESS BY INDEX ROWID| INDEXTEST          |     |    83 |     1   (0)00:00:01 |
|*  |   INDEX RANGE SCAN          | INDXTEST_OWNER_IDX |     |       |     1   (0)00:00:01 |
--------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   - access("OWNER"='SCOTT')

Note
-----
   - dynamic sampling used for this statement

SQL>
SQL>
SQL> analyze table indextest compute statistics for columns owner;

Table analyzed.

SQL>
SQL> select owner, object_name from indextest where owner='SYS';

Execution Plan
----------------------------------------------------------
Plan hash value: 2792531790

-------------------------------------------------------------------------------
| Id  | Operation         | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------
|   SELECT STATEMENT  |           |  7763 |   530K|    36   (3)00:00:01 |
|*  |  TABLE ACCESS FULL| INDEXTEST |  7763 |   530K|    36   (3)00:00:01 |
-------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   - filter("OWNER"='SYS')

Note
-----
   - dynamic sampling used for this statement

SQL>
SQL> select owner, object_name from indextest where owner='SCOTT';

Execution Plan
----------------------------------------------------------
Plan hash value: 3406603611

--------------------------------------------------------------------------------------------------
| Id  | Operation                   | Name               | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------------------
|   SELECT STATEMENT            |                    |     |    70 |     1   (0)00:00:01 |
|   |  TABLE ACCESS BY INDEX ROWID| INDEXTEST          |     |    70 |     1   (0)00:00:01 |
|*  |   INDEX RANGE SCAN          | INDXTEST_OWNER_IDX |     |       |     1   (0)00:00:01 |
--------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   - access("OWNER"='SCOTT')

Note
-----
   - dynamic sampling used for this statement

SQL>
SQL> set autotrace off
SQL> drop table indextest;

Table dropped.

SQL>

SQL>

 
Related examples in the same category
1. Compute Index statistics
2. Create index and check the Execution Plan
3. Autotrace a table with two indexes
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.