执行这样的SQL:
#1
explain plan for select * from student;
select * from table(dbms_xplan.display);
这样可以看到CBO估计出的值
#2
select /*+ gather_plan_statistics */ * from student where student_id < 3 and 1 = 2;
select sql_id from v$sql where sql_text like ‘
select /*+ gather_plan_statistics */ * from student where student_id < 3 and 1 = 2%’;
select * from table(dbms_xplan.display_cursor (
上一条语句查出的sql-id, null, ‘allstats’));
这样既可以看到CBO估计出的值,又可以看到运行时的统计值