optimizer_mode 之 all_rows

看oracle performance tuning guide时看到一句:

ALL_ROWS --The optimizer uses a cost-based approach for all SQL statements in the session regardless of the presence of statistics and optimizes with a goal of best throughput (minimum resource use to complete the entire statement).

于是做了个测试:

1.将scott这个schema的所有statistics删除。

1.1用

sql>explian for select * from emp;

sql>@?/rdbms/admin/utlxpls

看到cost,rows等信息已消失,符合optimizer mode的choose规则:当对table做了analyze后,会采用CBO,此时,cost,rows,bytes等信息可见。若无统计信息,则采用rule,此时上述信息不可见。

2.sql>alter system set optimizer_mode=all_rows scope=spfile;

3.sql>startup force后在看select * from emp;的执行计划,已能看到cost等信息。

证明当optimizer_mode设成all_rows时,会自动采用CBO.

[@more@]

请使用浏览器的分享功能分享到微信等