ITPub博客

首页 > IT职业 > IT生活 > 对CBO的一点困惑。求解!求解阿!

对CBO的一点困惑。求解!求解阿!

原创 IT生活 作者:gugu99 时间:2007-12-24 21:30:59 0 删除 编辑
对CBO的一点困惑。求解!求解阿!

今天metalink上看了这个文档说:
''
Literal SQL versus Shared SQL
To give a balanced picture this short section describes the benefits of both literal SQL and sharable SQL.
Literal SQL
The Cost Based Optimizer (CBO) works best when it has full statistics and when statements use literals in their predicates. Consider the following:
SELECT distinct cust_ref FROM orders WHERE total_cost < 10000.0;
versus
SELECT distinct cust_ref FROM orders WHERE total_cost < :bindA;
For the first statement the CBO could use histogram statistics that have been gathered to decide if it would be fastest to do a full table scan of ORDERS or to use an index scan on TOTAL_COST (assuming there is one). In the second statement CBO has no idea what percentage of rows fall below ":bindA" as it has no value for this bind variable to determine an execution plan . Eg: ":bindA" could be 0.0 or 99999999999999999.9
There could be orders of magnitude difference in the response time between the two execution paths so using the literal statement is preferable if you want CBO to work out the best execution plan for you. This is typical of Decision Support Systems where there may not be any 'standard' statements which are issued repeatedly so the chance of sharing a statement is small. Also the amount of CPU spent on parsing is typically only a small percentage of that used to execute each statement so it is probably more important to give the optimizer as much information as possible than to minimize parse times.
''
之前一直认为把cursor_sharing 改成Force才会造成计划失误。
照这个文档的说法绑定变量就要造成计划失误,绑和不绑是2难得,绑了计划失误,不绑造成parse time.
谁能明确说下到底则么回事?
[@more@]

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

请登录后发表评论 登录
全部评论
  • 博文量
    3121
  • 访问量
    2643809