一张10000条记录的表c1
create table c1 as select * from dba_objects where rownum <10001;
exec dbms_stats.gather_table_stats(user,'c1',estimate_percent=> 1);
按照理解,sample_size应该是10000*1%=100条左右
实际上
select sample_size from user_tables where table_name ='T1';
结果大致会在4400-5900附近。
而500000条记录的表,sample size也在5000附近。
原因在哪里呢?
打开SQL_TRACE
alter session set sql_trace=true;
exec dbms_stats.gather_table_stats(user,'t1',estimate_percent=> 1);
alter session set sql_trace=false;
select sample_size from user_tables where table_name ='C1';
4725
select value from v$diag_info where name='Default Trace File';
E:\APP\ADMINISTRATOR\diag\rdbms\orcl\orcl\trace\orcl_ora_23220.trc
这个是trace文件放的位置
cd E:\APP\ADMINISTRATOR\diag\rdbms\orcl\orcl\trace\
e:\
tkprof orcl_ora_23220.trc a.trc