Question: I need to see historical SQL with the
bind variables used. Does AWR or STATSPACK store bind variable
information? Does Oracle store SQL bind variable values anywhere?
Answer: Only the PGA stores specific bind
variable and cursor values, and these are not kept for historical
analysis.
The extra cost AWR allows you to see a “representative” sample
bind variable value, but all bind variable values are NOT present.
In Oracle 10g and beyond, bind variables are periodically captured
in the
v$sql_bind_capture and
dba_hist_sqlbind views, but these are bind variables or
ONLY for a single, specific session, and not all historical session
bind variables for a SQL statement are kept.
This is because the amount of disk storage to keep a history of
all bind variable values would be huge, especially for database that
process thousands of transactions per second.
These limited bind values can be found in some AWR and ASH tables
as well as the v$sql_plan view. Also, DML statements will
have bind variable information in the archived redo logs available
via LogMiner.
The best way to collect bind variable for any SQL statement is by
using
TKPROF (a 10046 trace).
v$sql_plan Bind Variable Display
The v$sql_plan only shows Systemwide values and it does
not contain session-level bind variable values. However, you can
use the
dbms_xplan.display package to display a sample bind
variable:
select
sql_text,
other_xml
from
$sql_plan
where
sql_id=’XXXX’
and
id=0;
AWR dba_hist_sqlstat
Bind Variable Display
select
sql_text,
other_xml
from
$dba_hist_sqlplan
where
sql_id=’XXXX’
and
id=0;
Or you can use the
dbms_xplan_display_awr procedure to see a sample bind
variable:
select
*
from
table(dbms_xplan.display_awr(‘&SQL_ID’,NULL,NULL,’ADVANCED’))
|
|
|
|
Guarantee your Success!
Oracle is the
world's most complex, robust and flexible database, considered
impossible to master without a mentor.
That's why all BC
Oracle trainers are working professionals, experts in Oracle who
share their tips and secrets. |
|
| |
|
Burleson is the American Team

Note:
This Oracle
documentation was created as a support and Oracle training reference for use by our
DBA performance tuning consulting professionals.
Feel free to ask questions on our
Oracle forum.
Verify
experience!
Anyone
considering using the services of an Oracle support expert should
independently investigate their credentials and experience, and not rely on
advertisements and self-proclaimed expertise. All legitimate Oracle experts
publish
their Oracle
qualifications.
Errata?
Oracle technology is changing and we
strive to update our BC Oracle support information. If you find an error
or have a suggestion for improving our content, we would appreciate your
feedback. Just
e-mail:
and include the URL for the page.
Copyright ? 1996 - 2012
All rights reserved.
Oracle ?
is the registered trademark of Oracle Corporation.
|
|