[原文]
Parsing is the process of:
* Translating a SQL statement, verifying it to be a valid statement
*
Performing data dictionary lookups to check table and column definitions
*
Acquiring parse locks on required objects so that their definitions do not
change during the statement’s parsing
* Checking privileges to access
referenced schema objects
* Determining the optimal execution plan for the
statement
* Loading it into a shared SQL area
* Routing all or part of
distributed statements to remote nodes that contain referenced
data
[译文]
SQL的解析过程:
1. 翻译SQL语句, 检查语法是否合法.
2. 查找数据字典以确认表和字段的定义是否正确.
3. 得到所需对象的解析锁,
目的是在解析的过程中对象的定义不会发生变化.
4. 检查所引用的数据库对象的访问权限.
5. 决定语句的最佳执行计划.
6.
将它载入共享SQL区中.
7. 对分布式语句中包含的引用数据, 定位它们所在的远程节点.
[理解]
根据以上的解析过程, 推理以下操作会导致
cursor 失效, sql重新解析:
1. SQL所依赖的数据库对象的结构发生变动(ALTER TABLE/VIEW/FUNCTION),
这个过程是传递的, 比如ALTER
TABLE, 会导致依赖这个TABLE的VIEW失效,
那么这时依赖这个VIEW的 cursor 也会相应失效.
2.
SQL所依赖的数据库对象的权限发生变动(GRANT/REVOKE).
3.
SQL所依赖的数据库对象的统计信息发生变动(ANALYZE/DBMS_STATS).
4. 刷新share pool(ALTER SYSTEM FLUSH
SHARED_POOL).
5. SQL所依赖的DBLINK被删除.
[重新解析带来的问题]
当开启 bind value peeking
时, 解析的时候会重新 peeking.这个时候生成的执行计划不可控.