Archives January 2021

PRCR-1079 : Failed to start resource ora.asm;CRS-5017: The resource action “ora.asm start” encountered the following error:;ORA-56865: Invalid IP address in CELLINIT.ORA;. For details refer to “(:CLSN00107:)” in “/apps01/base/product/11.2.0/grid/log/ exdbadm01/agent/ohasd/oraagent_oracle/oraagent_oracle.log”. (EXADATA)

Cause:

ASM cant start because of miscommunication between compute and cell nodes

[oracle@exdbadm01 ~]$ oerr ora 56865
56865, 00000, "Invalid IP address in CELLINIT.ORA"
// *Document: YES
// *Cause:   One or more of the specified IP addresses in CELLINIT.ORA is not
//           valid.
// *Action:  Check that all IP addresses in CELLINIT.ORA are valid.

Solution:

Verify the ipaddress in cellinit.ora file on all cell nodes

[root@exceladm00 celladmin]# cat /opt/oracle/cell11.2.3.2.1_LINUX.X64_130109/cellsrv/deploy/config/cellinit.ora
#CELL Initialization Parameters
version=0.0
HTTP_PORT=8888
bbuChargeThreshold=800
SSL_PORT=23943
RMI_PORT=23791
ipaddress1=10.10.1.11/24
bbuTempThreshold=60
DEPLOYED=TRUE
JMS_PORT=9127
BMC_SNMP_PORT=162

Check if the rds protocols are enabled on the cellnodes

[root@exceladm00 celladmin]# lsmod|grep rds
rds_rdma              106561  0
rds_tcp                48097  0
rds                   155561  260 rds_rdma,rds_tcp
rdma_cm                73429  2 rds_rdma,ib_iser
ib_core               108097  8 rds_rdma,ib_iser,rdma_cm,ib_cm,iw_cm,ib_sa,ib_mad,iw_cxgb3

If not enabled,then start the protocols

[root@exceladm00 celladmin]# /sbin/modprobe rds-tcp
[root@exceladm00 celladmin]# /sbin/modprobe rds_rdma
[root@exceladm00 celladmin]#  modprobe rds

Verify that all the griddisks in cell node are visible from compute node

[root@exdbadm01 oracle]#  /grid/stage/ext/bin/kfod op=disks disk=all
--------------------------------------------------------------------------------
 Disk          Size Path                                     User     Group
================================================================================
   1:        976 Mb o/192.168.56.69/DATA_CD_cell01_exceladm00 <unknown> <unknown>
   2:        976 Mb o/192.168.56.69/DATA_CD_cell02_exceladm00 <unknown> <unknown>
   3:        976 Mb o/192.168.56.69/DATA_CD_cell03_exceladm00 <unknown> <unknown>
   4:        976 Mb o/192.168.56.69/DATA_CD_cell04_exceladm00 <unknown> <unknown>
   5:        976 Mb o/192.168.56.69/DATA_CD_cell05_exceladm00 <unknown> <unknown>
   6:        976 Mb o/192.168.56.69/DATA_CD_cell06_exceladm00 <unknown> <unknown>
   7:        976 Mb o/192.168.56.69/FRA_CD_cell07_exceladm00 <unknown> <unknown>
   8:        976 Mb o/192.168.56.69/FRA_CD_cell08_exceladm00 <unknown> <unknown>
   9:        976 Mb o/192.168.56.69/FRA_CD_cell09_exceladm00 <unknown> <unknown>
  10:        976 Mb o/192.168.56.69/FRA_CD_cell10_exceladm00 <unknown> <unknown>
  11:        976 Mb o/192.168.56.69/MGMT_CD_cell11_exceladm00 <unknown> <unknown>
  12:        976 Mb o/192.168.56.69/MGMT_CD_cell12_exceladm00 <unknown> <unknown>

Start the asm

[oracle@exdbadm01 ~]$ . oraenv
ORACLE_SID = [oracle] ? +ASM
The Oracle base has been set to /apps01/base
[oracle@exdbadm01 ~]$ srvctl start asm

Check status of asm

[root@exdbadm01 oracle]# srvctl status asm
ASM is running on exdbadm01
ORA-02096: specified initialization parameter is not modifiable with this option

Cause:

You try to modify a parameter online without saving the changes to spfile

02096, 00000, "specified initialization parameter is not modifiable with this option"
// *Cause: Though the initialization parameter is modifiable, it cannot be
//         modified using the specified command.
// *Action: Check the DBA guide for information about under what scope
//          the parameter may be modified

Solution:

There are two types of parameters

one is static and other is dynamic

Dynamic parameters can be modified,when the instance is up and running without a database bounce and can be modified at memory level

Static parameters can be modified,when the instance is up and running but require a reboot for the changes to get reflected on database and it can be modified only at spfile level not in memory

For example,you can see the parameters which can and cant be modified in ISINSTANCE_MODIFIABLE column of v$parameter view

SQL> set lines 200
SQL> set pages 1000
SQL> select name,ISINSTANCE_MODIFIABLE from v$parameter;

NAME                                                                             ISINS <------
-------------------------------------------------------------------------------- -----
lock_name_space                                                                  FALSE(static)
processes                                                                        FALSE(static)
sessions                                                                         TRUE(dynamic)

If i try to modify the static parameter,i get the error

SQL> show parameter processes;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
processes                            integer     200


SQL> alter system set processes=300;
alter system set processes=300
                 *
ERROR at line 1:
ORA-02095: specified initialization parameter cannot be modified <---------


SQL> alter system set processes=300 scope=spfile; <-------

System altered.

SQL> shu immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORACLE instance started.

Total System Global Area 1572861600 bytes
Fixed Size                  8910496 bytes
Variable Size            1132462080 bytes
Database Buffers          423624704 bytes
Redo Buffers                7864320 bytes
Database mounted.
Database opened.

In alertlog, you can monitor the number of process gets modified with the value which was set earlier

[oracle@orcl19x ~]$ tail -f /data01/base/diag/rdbms/orcl19x1/orcl19x1/trace/alert_orcl19x1.log|grep processes
Shutting down archive processes
  processes                = 300 <-----

I can modify the dynamic parameter in fact without a reboot!

SQL> select name,ISINSTANCE_MODIFIABLE from v$parameter where name='optimizer_use_invisible_indexes';

NAME                                                                             ISINS
-------------------------------------------------------------------------------- -----
optimizer_use_invisible_indexes                                                  TRUE <---(Dynamic)


SQL> show parameter optimizer_use_invisible_indexes;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
optimizer_use_invisible_indexes      boolean     TRUE
SQL> alter system set optimizer_use_invisible_indexes=FALSE;

System altered.

SQL> show parameter optimizer_use_invisible_indexes;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
optimizer_use_invisible_indexes      boolean     FALSE

PLS-00201: identifier ‘DBMS_SYSTEM.SET_SQL_TRACE_IN_SESSION’ must be declared

Cause:

Appropriate permissions are not in place for the procedure,function or package for user!

SQL> exec dbms_system.set_sql_trace_in_session(sid=>123,serial#=>1234,sql_trace=                         >TRUE);
BEGIN dbms_system.set_sql_trace_in_session(sid=>123,serial#=>1234,sql_trace=>TRU                         E); END;

      *
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00201: identifier 'DBMS_SYSTEM.SET_SQL_TRACE_IN_SESSION' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

SQL>  exec dbms_system.set_sql_trace_in_session(sid=>123,serial#=>1234,sql_trace=TRUE);
BEGIN dbms_system.set_sql_trace_in_session(sid=>123,serial#=>1234,sql_trace=TRUE); END;

                                                                  *
ERROR at line 1:
ORA-06550: line 1, column 67:
PLS-00201: identifier 'SQL_TRACE' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

Solution:

Even though the user has dba privilege,still the user couldnot execute the packages of SYS and you can also create a public synonym for this package

Grant the privilege using sysdba account

SQL> conn / as sysdba
Connected.

SQL> create public synonym dbms_system for dbms_system;

Synonym created.

SQL> grant execute on dbms_system to test;

Grant succeeded.

SQL>  grant all on dbms_system to test;

Grant succeeded.

Check the privilege given

SQL> select distinct 'GRANT '||privilege||' ON '||OWNER||'.'||TABLE_NAME||' TO '||GRANTEE from DBA_TAB_PRIVS where grantee='TEST';

'GRANT'||PRIVILEGE||'ON'||OWNER||'.'||TABLE_NAME||'TO'||GRANTEE
--------------------------------------------------------------------------------
GRANT EXECUTE ON SYS.DBMS_SYSTEM TO TEST
GRANT DEBUG ON SYS.DBMS_SYSTEM TO TEST

It works fine now

SQL>  exec dbms_system.set_sql_trace_in_session(45,14530,TRUE);

PL/SQL procedure successfully completed.

SQL> show user
USER is "TEST"

ORA-01743: only pure functions can be indexed

Cause:

While creating function based index,you should give deterministic keyword for oracle to understand the function you create

You should not give sysdate,user etc.. inside a function

01743, 00000, "only pure functions can be indexed"
// *Cause: The indexed function uses SYSDATE or the user environment.
// *Action: PL/SQL functions must be pure (RNDS, RNPS, WNDS, WNPS).  SQL
//          expressions must not use SYSDATE, USER, USERENV(), or anything
//          else dependent on the session state.  NLS-dependent functions
//          are OK.

Solution:

The function you give to functional based index should return the same result for same parameters

eg:

Don’t

SQL> create index fn_order_date on sales(trunc(sysdate));
create index fn_order_date on sales(trunc(sysdate))
                                          *
ERROR at line 1:
ORA-01743: only pure functions can be indexed

Do

SQL> create index fn_order_date on sales(trunc(order_date));

Index created.

ORA-10631: SHRINK clause should not be specified for this object

Cause:

The solution for this error by oerr utility is not detailed

However,this issue is due to function based indexes existing on the table and we try to shrink the space in table to reduce fragmentation

SQL> !oerr ora 10631
10631, 00000, “SHRINK clause should not be specified for this object”
// *Cause: It is incorrect to issue shrink on the object
// *Action: Verify the object name and type and reissue the command

SQL> alter table test1.sales shrink space;
alter table test1.sales shrink space
*
ERROR at line 1:
ORA-10631: SHRINK clause should not be specified for this object

Solution:

Only way to overcome this error is to drop the index and recreate it

Identify the function index and drop it

SQL> select index_name from dba_indexes where owner='TEST1' and table_name='SALES';

INDEX_NAME
--------------------------------------------------------------------------------
PK_SALES_ID
FN_ORDER_DATE

SQL> set long 1000000
SQL> select dbms_metadata.get_ddl('INDEX','FN_ORDER_DATE') from dual;

DBMS_METADATA.GET_DDL('INDEX','FN_ORDER_DATE')
--------------------------------------------------------------------------------

  CREATE INDEX "TEST1"."FN_ORDER_DATE" ON "TEST1"."SALES" (TRUNC("ORDER_DATE"))

  PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"

Drop the index

SQL> alter index test1.FN_ORDER_DATE invisible;

Index altered.

SQL> alter table test1.sales shrink space;
alter table test1.sales shrink space
*
ERROR at line 1:
ORA-10631: SHRINK clause should not be specified for this object
SQL> alter index test1.FN_ORDER_DATE unusable;

Index altered.

SQL> alter table test1.sales shrink space;
alter table test1.sales shrink space
*
ERROR at line 1:
ORA-10631: SHRINK clause should not be specified for this object

SQL> drop index test1.FN_ORDER_DATE;

Index dropped.

SQL> alter table test1.sales shrink space;

Table altered.

After space shrink,rebuild the index

SQL> create index fn_order_date on sales(trunc(order_date));

Index created.

ORA-13602: The specified parameter RECOMMEND ALL is not valid for task or object Advisor.

Cause:

Make sure you give the right parameter in the advisor procedure

SQL> BEGIN
  2  dbms_advisor.set_task_parameter(
  3  task_name => 'Advisor',
  4  parameter => 'RECOMMEND ALL', <----- _underscore missed
  5  value => 'TRUE');
  6  END;
  7  /
BEGIN
*
ERROR at line 1:
ORA-13602: The specified parameter RECOMMEND ALL is not valid for task or
object Advisor.
ORA-06512: at "SYS.PRVT_ADVISOR", line 5010
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.PRVT_ADVISOR", line 1248
ORA-06512: at "SYS.PRVT_ADVISOR", line 4902
ORA-06512: at "SYS.DBMS_ADVISOR", line 401
ORA-06512: at line 2

Solution:

Check if you give correct parameter in set task parameter

This parameter stores various attributes that affect workload collection, tuning decisions and reporting.

SQL> BEGIN
  2  dbms_advisor.set_task_parameter(
  3  task_name => 'Advisor',
  4  parameter => 'RECOMMEND_ALL',
  5  value => 'TRUE');
  6  END;
  7  /

PL/SQL procedure successfully completed.

TBR-1001: Unable to create file

Cause:

The directory doesnot have proper permissions to create a file

Solution:

Give ownership and rwx permissions to the user from which you are trying to write

[root@tibero /]# chmod -R 775 tibero6/
[root@tibero /]# chown -R tibero:tinstall /tibero6/
TBS-70004: Not connected to the server.

Cause:

Make sure instance is started and you are connected to instance

You try to do operations in sql commandline without connecting to instance

Solution:

Connect to instance with credentials and status should reflect as connected to tibero

[tibero@tibero /]$ tbsql sys/tibero
ORA-02429: cannot drop index used for enforcement of unique/primary key

While dropping an index,all the constraints cascaded to that index should be either disabled or dropped

SQL> !oerr ora 02429
02429, 00000, "cannot drop index used for enforcement of unique/primary key"
// *Cause: user attempted to drop an index that is being used as the
//         enforcement mechanism for unique or primary key.
// *Action: drop the constraint instead of the index.

Solution:

Check the constraints related to that index

SQL> select constraint_name from dba_constraints where table_name in ('T','S');

CONSTRAINT_NAME
--------------------------------------------------------------------------------
PK_T
FK_T
PK_S

Primary key and foreign key for the table is disabled and respective index is wiped!

 SQL> alter table t disable constraint FK_T;

Table altered.

SQL> alter table s disable constraint PK_S;

Table altered.

Btree vs Bitmap index (oracle)

In this article,we will look at the difference,advantages and disadvantages of using btree(default) and bitmap index

Btree index has a balanced tree like structure with root,branch and leaf nodes.It is the most commonly used index for performance improvement.The index itself store the rowid and column values in a table.If we want to unleash the full potential of btree index,then all the table rowid and column values which needs to be fetched should be stored in index blocks.There are row pointers which points to the table directly from the leaf blocks in index.Basic btree structure looks something like below figure

BTREE STRUCTURE

Like btree index,bitmap index also has similar structure but stores the column values in the form of binary values with combination of 0 and 1.We can say dummy variables created for the low distinct values making an intersection point. The index key points to multiple rows in a table. The structure of bitmap looks similar to below figure.

The figure shows that we try to select a shirt detail from shirt table where the shirt size is medium and i want shirt colour which should be both red and orange. Here columns red and orange are unique columns in the bitmap index

BITMAP STRUCTURE

CARDINALITY :

Btree – high cardinality (high distinct values)

SQL> select count(distinct order_id) as HIGH_CARDINALITY_COLUMN from sales;

HIGH_CARDINALITY_COLUMN
-----------------------
                1048576

SQL> select count(*) from sales;

  COUNT(*)
----------
   1048576

Bitmap – low cardinality (less number of distinct values)

SQL> select count(distinct order_priority) as LOW_CARDINALITY_COLUMN from sales;

LOW_CARDINALITY_COLUMN
----------------------
                     4
SQL> select count(*) from sales;

  COUNT(*)
----------
   1048576

SIZE:

Btree – Consume more space

SQL> select segment_name,bytes/1024/1024 as SIZE_MB from dba_segments where segment_name in ('BTREE_SALES_IT','BTREE_SALES_PRIORI');

SEGMENT_NAME                                SIZE_MB
---------------------------------------- ----------
BTREE_SALES_IT                                   25 >---- 25MB
BTREE_SALES_PRIORI                               16 >---- 16MB

Bitmap – Consume less space compared to Btree provided there should be less distinct values and if high distinct values are present,then consume more space

SQL> column segment_name format a40
SQL> select segment_name,bytes/1024/1024 as SIZE_MB from dba_segments where segment_name in ('BTM_SALES_IT','BTM_SALES_PRIORI');

SEGMENT_NAME                                SIZE_MB
---------------------------------------- ----------
BTM_SALES_PRIORI                              .8125  <----- 0.8MB
BTM_SALES_IT                                      2  <----- 2MB

INDEX USAGE ON NULL VALUES :

Btree – Null values with indexed columns are not stored in Btree

Oracle ignores the index and goes for full table scan when there is a btree indexed null column

SQL> alter table sales add NULL_COLUMN varchar2(10);

Table altered.

SQL> select count(*),count(NULL_COLUMN) from sales;

  COUNT(*) COUNT(NULL_COLUMN)
---------- ------------------
   1048576                  0

SQL> select /*+index(sales btree)*/ count(*) from sales where null_column='';

Elapsed: 00:00:00.00

Execution Plan
----------------------------------------------------------
Plan hash value: 8150843

-----------------------------------------------------------------------------
| Id  | Operation           | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
-----------------------------------------------------------------------------
|   0 | SELECT STATEMENT    |       |     1 |     7 |     0   (0)|          |
|   1 |  SORT AGGREGATE     |       |     1 |     7 |            |          |
|*  2 |   FILTER            |       |       |       |            |          |
|   3 |    TABLE ACCESS FULL| SALES |  1048K|  7168K|  6482   (6)| 00:00:01 |
-----------------------------------------------------------------------------

Bitmap – Null values with indexed columns are stored in Bitmap

Oracle use bitmap index on null columns as well it doesnot matter

SQL> select /*+index(sales bitmap)*/ count(*) from sales where null_column='';

Elapsed: 00:00:00.01

Execution Plan
----------------------------------------------------------
Plan hash value: 633761674

-----------------------------------------------------------------------------------------
| Id  | Operation                      | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
-----------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT               |        |     1 |     7 |     0   (0)|          |
|   1 |  SORT AGGREGATE                |        |     1 |     7 |            |          |
|*  2 |   FILTER                       |        |       |       |            |          |
|   3 |    BITMAP CONVERSION COUNT     |        |  1048K|  7168K|    23   (0)| 00:00:01 |
|   4 |     BITMAP INDEX FAST FULL SCAN| BITMAP |       |       |            |          |
-----------------------------------------------------------------------------------------

SYNTAX :

Btree:

create index index_name on table_name(column_name);

SQL> create index btree_SALES_PRIORI on sales(ORDER_PRIORITY);

Index created.

Elapsed: 00:00:03.23 <------- Observe time taken to create btree index on less distinct column
SQL> create index btree_SALES_IT on sales(ITEM_TYPE);

Index created.

Elapsed: 00:00:05.75 <------- Highly time consuming when btree index created on less distinct columns!! :(

Bitmap:

create bitmap index index_name on table_name(column_name) nologging;

SQL> create bitmap index btm_sales_priori on sales(order_priority) nologging;

Index created.

Elapsed: 00:00:00.71 <---- less time taken to create bitmap in less distinct column :)
SQL> create bitmap index btm_sales_it on sales(item_type) nologging;

Index created.

Elapsed: 00:00:00.49 <--- less time taken to create bitmap in less distinct column :)

PURPOSE :

Btree – used for OLTP specifically for heavy DML transactions like INSERT,UPDATE and DELETE

Bitmap – used for OLAP specifically for STAR SCHEMAS with fact and dimension tables with frequent data retrieval like select queries with AND and OR operator in the where clause

DRAWBACKS:

Btree – Foreign key columns should be indexed which is referenced to a primary key column if not it cause locking issues

You will encounter below wait event with Row Exclusive Table Lock on parent table when there is an unindexed foreign key on a child table ,if the user forget to commit the data in case of btree index

  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  enq: TM - contention                            1        6.75          6.75

Bitmap – DML operations in bitmap indexed columns cause locking issues

So it is better to make bitmap index invisible or unusable when there is a DML load

creating bitmap index on high cardinality columns will

  • impact performance negatively
  • increase index size
  • index rebuild operation is time consuming

SUPPORTED EDITION:

Btree – default index supported in all editions

Bitmap – Supported in enterprise edition

EXECUTION PLAN:

Btree index on high distinct column: <—- See the time taken to create index ,number of physical IO,cost and size when btree created on high distinct column

SQL> create index btree_sales_id on sales(order_id);

Index created.

Elapsed: 00:00:02.98 <----
SQL> select segment_name,bytes/1024/1024 from dba_segments where segment_name='BTREE_SALES_ID';

SEGMENT_NAME                             BYTES/1024/1024
---------------------------------------- ---------------
BTREE_SALES_ID                                        19 <---

SQL> set timing on
SQL> set autot traceonly
SQL> select /*+index(btree_sales_id)*/ country,units_sold,unit_price,unit_cost,total_profit from sales where order_id between 123 and 1234;

1112 rows selected.

Elapsed: 00:00:00.02

Execution Plan
----------------------------------------------------------
Plan hash value: 1484275115

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

| Id  | Operation                           | Name           | Rows  | Bytes | C
ost (%CPU)| Time     |

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

|   0 | SELECT STATEMENT                    |                |  1113 | 48972 |
  36   (3)| 00:00:01 |

|   1 |  TABLE ACCESS BY INDEX ROWID BATCHED| SALES          |  1113 | 48972 |
  36   (3)| 00:00:01 |

|*  2 |   INDEX RANGE SCAN                  | BTREE_SALES_ID |  1113 |       |
   5   (0)| 00:00:01 |

--------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
          1  recursive calls
          0  db block gets
        179  consistent gets
         24  physical reads <----
          0  redo size
      46477  bytes sent via SQL*Net to client
       1309  bytes received via SQL*Net from client
         77  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
       1112  rows processed


Bitmap on high distinct column:<—- See the time taken to create,number of physical IO,cost and size when bitmap created on high distinct column

SQL> create bitmap index btm_sales_id on sales(order_id) nologging;

Index created.

Elapsed: 00:00:09.89 <------
SQL> select segment_name,bytes/1024/1024 from dba_segments where segment_name='BTM_SALES_ID';

SEGMENT_NAME                             BYTES/1024/1024
---------------------------------------- ---------------
BTM_SALES_ID                                          30 <-----


SQL> select /*+btm_sales_id*/ country,units_sold,unit_price,unit_cost,total_profit from sales where order_id between 123 and 1234;

1112 rows selected.

Elapsed: 00:00:00.07

Execution Plan
----------------------------------------------------------
Plan hash value: 1651313649

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

| Id  | Operation                           | Name         | Rows  | Bytes | Cos
t (%CPU)| Time     |

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

|   0 | SELECT STATEMENT                    |              |  1113 | 48972 |   2
54   (1)| 00:00:01 |

|   1 |  TABLE ACCESS BY INDEX ROWID BATCHED| SALES        |  1113 | 48972 |   2
54   (1)| 00:00:01 |

|   2 |   BITMAP CONVERSION TO ROWIDS       |              |       |       |
        |          |

|*  3 |    BITMAP INDEX RANGE SCAN          | BTM_SALES_ID |       |       |
        |          |

--------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
        239  recursive calls
          0  db block gets
        559  consistent gets
         87  physical reads <----
          0  redo size
      46278  bytes sent via SQL*Net to client
       1300  bytes received via SQL*Net from client
         76  SQL*Net roundtrips to/from client
         52  sorts (memory)
          0  sorts (disk)
       1112  rows processed

Btree:

Use btree index most of the time 99% unless there are specific requirement to use other indexes

Below is an example of highly distinct column

SQL> select count(order_id) from sales group by order_id having count(order_id) = 1 fetch next 10 rows only;

COUNT(ORDER_ID)
---------------
              1
              1
              1
              1
              1
              1
              1
              1
              1
              1

10 rows selected.

Bitmap:

Use bitmap index when a column has 1% distinct values from overall column

SQL> select count(order_priority) as ORDER_PRIORITY from sales group by order_priority having count(*) > 1;

ORDER_PRIORITY
--------------
        261964
        262329
        262160
        262123

Btree index on a low distinct column:<—- See number of physical IO and cost when btree created on low distinct column

SQL> select /*+index(sales btree_SALES_PRIORI) index(sales btree_SALES_IT)*/ country,ITEM_TYPE,SALES_CHANNEL,ORDER_PRIORITY from sales where item_type='Vegetables' and order_priority='L';

21769 rows selected.

Elapsed: 00:00:00.56

Execution Plan
----------------------------------------------------------
Plan hash value: 329813273

----------------------------------------------------------------------------------------------------------
| Id  | Operation                           | Name               | Rows  | Bytes | Cost (%CPU)| Time     |
----------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                    |                    | 21795 |   659K| 12458   (2)| 00:00:01 |
|*  1 |  TABLE ACCESS BY INDEX ROWID BATCHED| SALES              | 21795 |   659K| 12458   (2)| 00:00:01 |
|*  2 |   INDEX RANGE SCAN                  | BTREE_SALES_PRIORI |   262K|       |   519   (8)| 00:00:01 |
------------------------------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
          4  recursive calls
          0  db block gets
      15143  consistent gets
      12305  physical reads <-----
          0  redo size
     705620  bytes sent via SQL*Net to client
      16504  bytes received via SQL*Net from client
       1453  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
      21769  rows processed

Bitmap index on a low distinct column:<—- See effect of number of physical IO and cost when bitmap created on low distinct column

Creating bitmap indexes in multiple columns would enhance the data retrieval with lightning performance!

SQL> select country,ITEM_TYPE,SALES_CHANNEL,ORDER_PRIORITY from sales where item_type='Vegetables' and order_priority='L';

21769 rows selected.

Elapsed: 00:00:00.34

Execution Plan
----------------------------------------------------------
Plan hash value: 948039403

--------------------------------------------------------------------------------------------------------
| Id  | Operation                           | Name             | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                    |                  | 21845 |   661K|  2743   (1)| 00:00:01 |
|   1 |  TABLE ACCESS BY INDEX ROWID BATCHED| SALES            | 21845 |   661K|  2743   (1)| 00:00:01 |
|   2 |   BITMAP CONVERSION TO ROWIDS       |                  |       |       |            |          |
|   3 |    BITMAP AND                       |                  |       |       |            |          |
|*  4 |     BITMAP INDEX SINGLE VALUE       | BTM_SALES_IT     |       |       |            |          |
|*  5 |     BITMAP INDEX SINGLE VALUE       | BTM_SALES_PRIORI |       |       |            |          |
------------------------------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
         35  recursive calls
          5  db block gets
      12123  consistent gets
      10022  physical reads <-----
        956  redo size
     705400  bytes sent via SQL*Net to client
      16439  bytes received via SQL*Net from client
       1453  SQL*Net roundtrips to/from client
          2  sorts (memory)
          0  sorts (disk)
      21769  rows processed

From this post, it has been practically observed that both btree and bitmap index are very efficient in their own way and solve the purpose! we also learnt the basic differences between both indexes and where to effectively use them