Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a966451

Browse files
committed
Added cardinality to SQL on xmltable to avoid excessive estimates.
Resolves #752
1 parent f77c987 commit a966451

1 file changed

Lines changed: 30 additions & 27 deletions

File tree

source/expectations/data_values/ut_compound_data_helper.pkb

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -95,37 +95,39 @@ create or replace package body ut_compound_data_helper is
9595
with
9696
expected_cols as ( select :a_expected as item_data from dual ),
9797
actual_cols as ( select :a_actual as item_data from dual ),
98-
expected_cols_info as (
99-
select e.*,
98+
expected_cols_info as (
99+
select /*+ cardinality(e 100) */
100+
e.*,
100101
replace(expected_type,'VARCHAR2','CHAR') expected_type_compare
101102
from (
102-
SELECT rownum expected_pos,
103-
xt.name expected_name,
104-
xt.type expected_type
105-
FROM (select ]'||l_column_filter||q'[ from expected_cols ucd) x,
106-
XMLTABLE('/ROW/*'
107-
PASSING x.item_data
108-
COLUMNS
109-
name VARCHAR2(4000) PATH '@xml_valid_name',
110-
type VARCHAR2(4000) PATH '/'
111-
) xt
112-
) e
103+
select rownum expected_pos,
104+
xt.name expected_name,
105+
xt.type expected_type
106+
from (select ]'||l_column_filter||q'[ from expected_cols ucd) x,
107+
xmltable(
108+
'/ROW/*'
109+
passing x.item_data
110+
columns
111+
name varchar2(4000) PATH '@xml_valid_name',
112+
type varchar2(4000) PATH '/'
113+
) xt
114+
) e
113115
),
114116
actual_cols_info as (
115-
select a.*,
117+
select /*+ cardinality(a 100) */
118+
a.*,
116119
replace(actual_type,'VARCHAR2','CHAR') actual_type_compare
117-
from (
118-
SELECT rownum actual_pos,
119-
xt.name actual_name,
120-
xt.type actual_type
121-
FROM (select ]'||l_column_filter||q'[ from actual_cols ucd) x,
122-
XMLTABLE('/ROW/*'
123-
PASSING x.item_data
124-
COLUMNS
125-
name VARCHAR2(4000) PATH '@xml_valid_name',
126-
type VARCHAR2(4000) PATH '/'
127-
) xt
128-
) a
120+
from (select rownum actual_pos,
121+
xt.name actual_name,
122+
xt.type actual_type
123+
from (select ]'||l_column_filter||q'[ from actual_cols ucd) x,
124+
xmltable('/ROW/*'
125+
passing x.item_data
126+
columns
127+
name varchar2(4000) path '@xml_valid_name',
128+
type varchar2(4000) path '/'
129+
) xt
130+
) a
129131
),
130132
joined_cols as (
131133
select e.*, a.*,
@@ -134,7 +136,8 @@ create or replace package body ut_compound_data_helper is
134136
from expected_cols_info e
135137
full outer join actual_cols_info a on e.expected_name = a.actual_name
136138
)
137-
select case
139+
select /*+ cardinality(joined_cols 100)*/
140+
case
138141
when expected_pos is null and actual_pos is not null then '+'
139142
when expected_pos is not null and actual_pos is null then '-'
140143
when expected_type_compare != actual_type_compare then 't'

0 commit comments

Comments
 (0)