暂无图片
分享
liaju
2019-03-08
Oracle 的 SQL PLAN_HASH_VALUE=0 是什么意思?

很多时候发现SQL的

PLAN_HASH_VALUE=0

是什么意思讷?

PIC 1.jpg


收藏
分享
4条回答
默认
最新
Moone

这个是正常现象,主要发生在如下情况:

1、不带查询的INSERT/DELETE语句时,这些SQL无需执行计划

2、带绑定变量的SQL,仅进行了解析而没有实际执行,执行计划延迟生成。


参考MOS文档:Reasons for a SELECT to have a PLAN_HASH_VALUE of Zero (文档 ID 1587381.1)

暂无图片 评论
暂无图片 有用 0
章芋文

通常这种没有查询条件的INSERT和DELETE语句,不需要访问路径,也就没有执行计划,这个时候PLAN_HASH_VALUE就为0。

另外也存在极少数SELECT语句PLAN_HASH_VALUE为0的情况,参考官方说明:

The V$SQL view externalises various information about SQL statements that are being stored in the shared pool to users and one of these is the PLAN_HASH_VALUE which is a reference to the access path that has been generated for the a query. This is usually a large number but sometimes it is zero. When you are looking at a DELETE or an INSERT without a query, then a zero PLAN_HASH_VALUE is quite normal as there is no plan. In these cases no access path has been calculated and none is needed.

However it is possible to sometimes see a SELECT with a zero PLAN_HASH_VALUE which is less easy to explain.

The main reason for this is  key to this is that the query uses bind variables and the cursor has been parsed BUT the generation of an execution plan has been deferred until execution time since that is when the bind values will be supplied (which may have a significant bearing on the access path generated). Until the query is 'bound' and executed, there is no plan and so the PLAN_HASH_VALUE will be zero.

暂无图片 评论
暂无图片 有用 0
liaju

谢谢,了解了

暂无图片 评论
暂无图片 有用 0
liaju
问题已关闭: 问题已经得到解决
暂无图片 评论
暂无图片 有用 0
回答交流
提交
问题信息
请登录之后查看
邀请回答
暂无人订阅该标签,敬请期待~~
暂无图片墨值悬赏