-
Notifications
You must be signed in to change notification settings - Fork 318
/
Copy pathhinth.sql
57 lines (52 loc) · 1.71 KB
/
hinth.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
-- Copyright 2018 Tanel Poder. All rights reserved. More info at http://tanelpoder.com
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms & conditions.
--------------------------------------------------------------------------------
--
-- File name: hinth.sql (Hint Hierarchy)
--
-- Purpose: Display the areas / features in Oracle kernel that a hint affects
-- (displayed as a feature/module hierarchy)
--
-- Author: Tanel Poder
-- Copyright: (c) http://www.tanelpoder.com
--
-- Usage: @hinth <hint_name>
-- @hinth MERGE
--
-- Other: Requires Oracle 11g+
--
--------------------------------------------------------------------------------
COL sqlfh_feature HEAD SQL_FEATURE FOR A55
COL hinth_path HEAD PATH FOR A150
COL hinth_name HEAD NAME FOR A35
PROMPT Display Hint feature hierarchy for hints like &1
WITH feature_hierarchy AS (
SELECT
f.sql_feature
, SYS_CONNECT_BY_PATH(REPLACE(f.sql_feature, 'QKSFM_', ''), ' -> ') path
FROM
v$sql_feature f
, v$sql_feature_hierarchy fh
WHERE
f.sql_feature = fh.sql_feature
CONNECT BY fh.parent_id = PRIOR f.sql_Feature
START WITH fh.sql_feature = 'QKSFM_ALL'
)
SELECT
hi.name hinth_name
, REGEXP_REPLACE(fh.path, '^ -> ', '') hinth_path
, DECODE(BITAND(target_level,1),1,'STATEMENT ') ||
DECODE(BITAND(target_level,2),2,'QBLOCK ') ||
DECODE(BITAND(target_level,4),4,'OBJECT ') ||
DECODE(BITAND(target_level,8),8,'JOIN ') hint_scope
FROM
v$sql_hint hi
, feature_hierarchy fh
WHERE
hi.sql_feature = fh.sql_feature
-- hi.sql_feature = REGEXP_REPLACE(fh.sql_feature, '_[[:digit:]]+$')
AND UPPER(hi.name) LIKE UPPER('%&1%')
ORDER BY
path
--name
/