Created
February 28, 2025 02:30
-
-
Save xtender/bc67c659915d474ddee8c7aefd16617a to your computer and use it in GitHub Desktop.
index with basic compression for filter predicates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table t (a int,b int, c int, d int); | |
insert into t select 1, 1, level,level from dual connect by level<=100; | |
insert into t select 1, 5, level,level from dual connect by level<=100000; | |
insert into t select 1, 6, level,level from dual connect by level<=100000; | |
insert into t select 1, 7, level,level from dual connect by level<=100000; | |
insert into t select 10, 10, level,level from dual connect by level<=1; | |
insert into t select 11, 11, level,level from dual connect by level<=1; | |
create index t_ix on t(a,b,c) compress 2; | |
call dbms_stats.gather_table_stats('','T'); | |
select leaf_blocks from user_indexes where index_name='T_IX'; | |
select blocks from user_segments where segment_name='T_IX'; | |
select/*+ index_rs_asc(t) gather_plan_statistics */ count(*) from t where a<3 and b<3; | |
select * from dbms_xplan.display_cursor('','','allstats last'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SQL> select leaf_blocks from user_indexes where index_name='T_IX'; | |
LEAF_BLOCKS | |
----------- | |
666 | |
1 row selected. | |
SQL> select blocks from user_segments where segment_name='T_IX'; | |
BLOCKS | |
---------- | |
768 | |
1 row selected. | |
SQL> select/*+ index_rs_asc(t) gather_plan_statistics */ count(*) from t where a<3 and b<3; | |
COUNT(*) | |
---------- | |
100 | |
1 row selected. | |
SQL> select * from dbms_xplan.display_cursor('','','allstats last'); | |
PLAN_TABLE_OUTPUT | |
--------------------------------------------------------------------------------------------- | |
SQL_ID 7xwh91zzmznv0, child number 0 | |
------------------------------------- | |
select/*+ index_rs_asc(t) gather_plan_statistics */ count(*) from t | |
where a<3 and b<3 | |
Plan hash value: 3836941823 | |
--------------------------------------------------------------------------------------------- | |
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | Reads | | |
--------------------------------------------------------------------------------------------- | |
| 0 | SELECT STATEMENT | | 1 | | 1 |00:00:00.02 | 670 | 1 | | |
| 1 | SORT AGGREGATE | | 1 | 1 | 1 |00:00:00.02 | 670 | 1 | | |
|* 2 | INDEX RANGE SCAN| T_IX | 1 | 20007 | 100 |00:00:00.02 | 670 | 1 | | |
--------------------------------------------------------------------------------------------- | |
Predicate Information (identified by operation id): | |
--------------------------------------------------- | |
2 - access("A"<3 AND "B"<3) | |
filter("B"<3) | |
21 rows selected. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment