Have been waiting for while to post a series of various limitations associated with automatic indexing (AI), one of the most serious limitation is associate with range-based predicates, going to run a series of range-based predicates that heavily filter and would greatly benefit from an index.
2 nologging as
3 select a.*,
4 sysdate - mod(rownum,2800) as release_dt ,
5 ceil( dbms_random.value(1,500000) ) as sales_amt,
6 rownum as sales_id
7 from stage a, stage b, stage c
8 where rownum <= 10000000 ;
ai_demo@PDB19> select * from demo025 where sales_id between 42 and 50;
----------------------------------------------------------
Plan hash value: 625612404
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 10 | 1140 | 48595 (1)| 00:00:02 |
|* 1 | TABLE ACCESS STORAGE FULL| DEMO025 | 10 | 1140 | 48595 (1)| 00:00:02 |
-------------------------------------------------------------------------------------
---------------------------------------------------
filter("SALES_ID"<=50 AND "SALES_ID">=42)
----------------------------------------------------------
Plan hash value: 625612404
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 114 | 48595 (1)| 00:00:02 |
|* 1 | TABLE ACCESS STORAGE FULL| DEMO025 | 1 | 114 | 48595 (1)| 00:00:02 |
-------------------------------------------------------------------------------------
---------------------------------------------------
filter("SALES_ID"<0)
----------------------------------------------------------
Plan hash value: 625612404
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 114 | 48595 (1)| 00:00:02 |
|* 1 | TABLE ACCESS STORAGE FULL| DEMO025 | 1 | 114 | 48595 (1)| 00:00:02 |
-------------------------------------------------------------------------------------
---------------------------------------------------
filter("SALES_ID">10000000)
-------------------------------------------------------------------------------
Index candidates : 2
Indexes created (visible / invisible) : 1 (1 / 0)
Space used (visible / invisible) : 137.36 MB (137.36 MB / 0 B)
Indexes dropped : 0
SQL statements verified : 1
SQL statements improved (improvement factor) : 1 (10504.7x)
SQL plan baselines created : 0
Overall improvement factor : 10504.7x
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
Unused indexes : 0
Space used : 0 B
Unusable indexes : 0
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
1. The following indexes were created:
*: invisible
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
| Owner | Table | Index | Key | Type | Properties |
-------------------------------------------------------------------------------
| AI_DEMO | DEMO023 | SYS_AI_11muvn2pw0ym6 | RELEASE_DT | B-TREE | LOCAL |
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
No comments:
Post a Comment