-- 问题:
当某字段上有索引的表返回少量数据(如,10%数据)时,优化器一定会走索引吗?
-- 实验:
-- 1.建立两张表
-- a.T1表
--drop table t1 purge ;
create table t1 nologging as
select trunc((rownum-1)/100) id
,rpad(rownum,100) t_pad
from dba_source
where rownum <= 10000 ;
create index t1_idx1 on t1(id) ;
select owner,segment_name
,bytes/1024/1024
from dba_segments
where segment_name = 't1'
;
exec dbms_stats.gather_table_stats( 'SYS','t1',method_opt => 'FOR ALL COLUMNS SIZE 1',cascade => TRUE) ;
-- b.T2表
--drop table t2 purge ;
create table t2 nologging as
select mod(rownum,100) id
,rpad(rownum,100) t_pad
from dba_source
where rownum <=
当某字段上有索引的表返回少量数据(如,10%数据)时,优化器一定会走索引吗?
-- 实验:
-- 1.建立两张表
-- a.T1表
--drop table t1 purge ;
create table t1 nologging as
select trunc((rownum-1)/100) id
,rpad(rownum,100) t_pad
from dba_source
where rownum <= 10000 ;
create index t1_idx1 on t1(id) ;
select owner,segment_name
,bytes/1024/1024
from dba_segments
where segment_name = 't1'
;
exec dbms_stats.gather_table_stats( 'SYS','t1',method_opt => 'FOR ALL COLUMNS SIZE 1',cascade => TRUE) ;
-- b.T2表
--drop table t2 purge ;
create table t2 nologging as
select mod(rownum,100) id
,rpad(rownum,100) t_pad
from dba_source
where rownum <=