ITPub博客

首页 > 数据库 > 数据库开发技术 > 一条语句被解析parse的过程

一条语句被解析parse的过程

原创 数据库开发技术 作者:littledan 时间:2007-03-11 18:26:28 0 删除 编辑

一条语句被解析parse的过程


2006-11-22 00:35:42 / 个人分类:administration <http://blog.oracle.com.cn/47810/spacelist_type_blog_itemtypeid_144.html>

SQL Parsing Flow Diagram ========================

Statement
Submitted
|
Is it in an open cursor?--------------YES----V
| |
NO |
| |
Is SESSION_CACHED_CURSORS = Value |
and cursor in --------------YES----V In these 3 cases we
Session Cursor cache? | know that the cursor has
| | already been parsed, so
NO | re-parsing is
| | unnecessary.
Is HOLD_CURSOR=Y |
and cursor in --------------YES----V
Held cursor cache? |
| |
NO |
| | ^
OPEN A CURSOR | CLIENT SIDE |
| | -------------|
Statement is Hashed and compared | SERVER SIDE |
with the Hashed value in the sql area | V
| V
Is it in sql area? --YES-(Soft Parse)--> ---------
| | |
NO | EXECUTE |
| | |
PARSE STATEMENT ('Hard' Parse)---------> ---------


NOTES
=====

1. A cursor is an address on the client that points to the memory
location of a SQL statement on the server.
Multiple-client cursors may point at the same address on the server.

2. Remember that 'Client' and 'Server' sides may reside on the same
machine - in which case Client/Server is a logical distinction.

3. If a cursor is open, then the statement will be in the sql_area,
so no parsing is necessary.

This is why locks may remain when a client is terminated
abnormally (such as a PC Client being turned off without
closing open cursors).

4. SESSION_CACHED_CURSORS is the initialisation parameter that
specifies how many cursors to hold open for a particular session.

5. HOLD_CURSOR is an precompiler parameter that specifies that an
individual cursor should be held open.

See Page 11-3 of the Programmer's guide to the Oracle Precompilers.

6. Both the soft and hard parse register as a parse in tkprof. Hashing the
current statement updates the parse count.

7. Soft parse avoids many of the steps taken during the parse phase for a
particular statement. Initial syntactic and semantic checks are made and
then the statement is hashed and compared with hashed statements in
the SQL area. If a match is found, then existing information is used
and relatively expensive steps (such as query optimization etc.) are avoided.

8. The 10053 event is only invoked during a hard parse.

From:Note:32895.1

[@more@]

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

请登录后发表评论 登录
全部评论

注册时间:2008-01-13

  • 博文量
    31
  • 访问量
    137718