drop table test_par
/

create table test_par
   (
   col1 number not null,
   col2 number not null
   )
nologging compress pctfree 0
partition by range (col1)
(partition p1_to_4 values less than (5),
partition p5 values less than (6)
)
/

insert /*+ append */ into test_par
select mod(rownum,4)+1,rownum
from dual
connect by level <= 100000
/

create bitmap index idx02_test_par
on test_par (col2)
local nologging
/

begin
DBMS_STATS.GATHER_TABLE_STATS (
   ownname          => user,
   tabname          => 'test_par',
   partname         => null,
   estimate_percent => 100,
   block_sample     => false,
   method_opt       => 'for all columns size 1',
   degree           => null,
   granularity      => 'ALL',
   cascade          => true,
   stattab          => NULL, 
   statid           => NULL,
   statown          => NULL,
   no_invalidate    => FALSE);
end;
/

set linesize 500 pagesize 0

variable l_col1 number

define l_col1 = 5
truncate table plan_table
/
explain plan for
select count(*) from test_par
where col1 = :l_col1
/

select * from table (dbms_xplan.display)
/

define l_col1 = 1
truncate table plan_table
/

explain plan for
select count(*) from test_par
where col1 = :l_col1
/

select * from table (dbms_xplan.display)
/
truncate table plan_table
/

explain plan for
select count(*) from test_par
where col1 = 5
/

select * from table (dbms_xplan.display)
/
truncate table plan_table
/

explain plan for
select count(*) from test_par
where col1 =1
/

select * from table (dbms_xplan.display)
/

