很多时候发现SQL的
PLAN_HASH_VALUE=0
是什么意思讷?

这个是正常现象,主要发生在如下情况:
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
墨值悬赏

