檢視SQL PROFILE使用的HINT

wei-xh發表於2013-09-29
10G可以透過如下查詢來獲取SQL PROFILE使用的HINT
SQL> SELECT attr_val
  2  FROM sys.sqlprof$ p, sys.sqlprof$attr a
  3  WHERE p.sp_name = 'opt_estimate'
  4  AND p.signature = a.signature
  5  AND p.category = a.category;

ATTR_VAL
---------------------------------------------------------------------------------
OPT_ESTIMATE(@"SEL$1", JOIN, ("T"@"SEL$1", "CH"@"SEL$1"), SCALE_ROWS=276.7754079)
OPT_ESTIMATE(@"SEL$1", TABLE, "CH"@"SEL$1", SCALE_ROWS=40.15499105)
11G後這個查詢不再有效,實際上涉及到的底層表也已經改變。可以透過如下查詢獲取:
SQL> SELECT extractValue(value(h),'.') AS hint
  2  FROM sys.sqlobj$data od, sys.sqlobj$ so,
  3  table(xmlsequence(extract(xmltype(od.comp_data),'/outline_data/hint'))) h
  4  WHERE so.name = 'opt_estimate'
  5  AND so.signature = od.signature
  6  AND so.category = od.category
  7  AND so.obj_type = od.obj_type
  8  AND so.plan_id = od.plan_id;

HINT
---------------------------------------------------------------------------------
OPT_ESTIMATE(@"SEL$1", TABLE, "CH"@"SEL$1", SCALE_ROWS=39.20843548)
OPT_ESTIMATE(@"SEL$1", JOIN, ("T"@"SEL$1", "CH"@"SEL$1"), SCALE_ROWS=281.2054138)
OPTIMIZER_FEATURES_ENABLE(default)

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22034023/viewspace-773590/,如需轉載,請註明出處,否則將追究法律責任。

相關文章