Cursor Sharing
Hard Parses can be
largely reduced using Bind Variables.
Actually, Oracle
differentiates between parent and child cursor stored in the Shared Pool area.
Every parsed SQL
statement has a parent
cursor and
one or more child cursors. The parent cursor stores the text of the SQL
statement. If the text of two statements is identical, then the statements
share the same parent cursor. If the text is different, however, then the
database creates a separate parent cursor.
Every parent cursor has
one or more child
cursors.
A child cursor contains the execution plan, bind variables, metadata
about objects referenced in the query, optimizer environment, and other
information. In contrast to the parent cursor, the child cursor does not store
the text of the SQL statement.
Oracle generates child
cursors (linked to an unique parent cursor) for nearly 60 reasons. The
optimizer decides whether to generate a cursor or not, for example, using
cardinality feedbacks, that are sql execution statistics. In this way, for next
sql executions, the Optimizer can make his choice evaluating more than one
plan, without executing an actual Hard Parse.
In this case we could
say that the DB is executing an “Harder” Soft Parse:
This is very useful
because can reduce cardinality impact on execution costs. The v$sql_shared_cursor view contains the reason why a
certain cursor exists (and why it is not shared with existing child cursors).
In fact, this view has more than 60 columns and each column identifies a
specific reason why the cursor can’t be shared.
No comments:
Post a Comment