optimizer_mode 之 all_rows

本文通过实验证明,在Oracle数据库中设置optimizer_mode为ALL_ROWS时,即使表没有统计信息,优化器也会使用基于成本的方法(CBO)来优化SQL语句。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

看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@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/3345/viewspace-995912/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/3345/viewspace-995912/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值