diff --git a/sql/_35_fig_cake/cbrd_25382/answers/cbrd_25382_1.answer b/sql/_35_fig_cake/cbrd_25382/answers/cbrd_25382_1.answer new file mode 100755 index 0000000000..86970a2af3 --- /dev/null +++ b/sql/_35_fig_cake/cbrd_25382/answers/cbrd_25382_1.answer @@ -0,0 +1,504 @@ +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +2000 +=================================================== +2000 +=================================================== +2000 +=================================================== +2000 +=================================================== +2000 +=================================================== +2000 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== + +#### 1. build input: small tuple count + +=================================================== +count(*) +20 + +Query plan: +hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: iscan + class: c node[?] + index: i_b term[?] + cost: ? card ? + inner: iscan + class: d node[?] + index: i_b term[?] + cost: ? card ? + cost: ? card ? + inner: iscan + class: b node[?] + index: i_b term[?] + cost: ? card ? + cost: ? card ? + inner: iscan + class: a node[?] + index: i_b term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ USE_HASH */ count(*) from ta a, tb b, tc c, td d where a.cd=b.cd and b.cd=c.cd and c.cd=d.cd and ((a.cb= ?:? ) or (a.cb= ?:? )) and ((b.cb= ?:? ) or (b.cb= ?:? ) or (b.cb= ?:? )) and ((c.cb= ?:? ) or (c.cb= ?:? ) or (c.cb= ?:? ) or (c.cb= ?:? )) and d.cb= ?:? +=================================================== +trace + +Query Plan: + HASH JOIN (inner join) + HASH JOIN (inner join) + HASH JOIN (inner join) + INDEX SCAN (c.i_b) (key range: ((c.cb= ?:? ) or (c.cb= ?:? ) or (c.cb= ?:? ) or (c.cb= ?:? ))) + INDEX SCAN (d.i_b) (key range: d.cb= ?:? ) + INDEX SCAN (b.i_b) (key range: ((b.cb= ?:? ) or (b.cb= ?:? ) or (b.cb= ?:? ))) + INDEX SCAN (a.i_b) (key range: ((a.cb= ?:? ) or (a.cb= ?:? ))) + + rewritten query: select /*+ USE_HASH */ count(*) from [dba.ta] a, [dba.tb] b, [dba.tc] c, [dba.td] d where a.cd=b.cd and b.cd=c.cd and c.cd=d.cd and ((a.cb= ?:? ) or (a.cb= ?:? )) and ((b.cb= ?:? ) or (b.cb= ?:? ) or (b.cb= ?:? )) and ((c.cb= ?:? ) or (c.cb= ?:? ) or (c.cb= ?:? ) or (c.cb= ?:? )) and d.cb= ?:? + +Trace Statistics: + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: memory) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: memory) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: memory) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (index: dba.td.i_b), (btree time: ?, fetch: ?, ioread: ?, readkeys: ?, filteredkeys: ?, rows: ?) (lookup time: ?, rows: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (index: dba.tc.i_b), (btree time: ?, fetch: ?, ioread: ?, readkeys: ?, filteredkeys: ?, rows: ?) (lookup time: ?, rows: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (index: dba.tb.i_b), (btree time: ?, fetch: ?, ioread: ?, readkeys: ?, filteredkeys: ?, rows: ?) (lookup time: ?, rows: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (index: dba.ta.i_b), (btree time: ?, fetch: ?, ioread: ?, readkeys: ?, filteredkeys: ?, rows: ?) (lookup time: ?, rows: ?) + + +=================================================== +0 +=================================================== + +#### 2. build input: small tuple count + ordered + +=================================================== +count(*) +20 + +Query plan: +hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: iscan + class: a node[?] + index: i_b term[?] + cost: ? card ? + inner: iscan + class: b node[?] + index: i_b term[?] + cost: ? card ? + cost: ? card ? + inner: iscan + class: c node[?] + index: i_b term[?] + cost: ? card ? + cost: ? card ? + inner: iscan + class: d node[?] + index: i_b term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH */ count(*) from ta a, tb b, tc c, td d where a.cd=b.cd and b.cd=c.cd and c.cd=d.cd and ((a.cb= ?:? ) or (a.cb= ?:? ) or (a.cb= ?:? )) and ((b.cb= ?:? ) or (b.cb= ?:? ) or (b.cb= ?:? ) or (b.cb= ?:? )) and ((d.cb= ?:? ) or (d.cb= ?:? )) and c.cb= ?:? +=================================================== +trace + +Query Plan: + HASH JOIN (inner join) + HASH JOIN (inner join) + HASH JOIN (inner join) + INDEX SCAN (a.i_b) (key range: ((a.cb= ?:? ) or (a.cb= ?:? ) or (a.cb= ?:? ))) + INDEX SCAN (b.i_b) (key range: ((b.cb= ?:? ) or (b.cb= ?:? ) or (b.cb= ?:? ) or (b.cb= ?:? ))) + INDEX SCAN (c.i_b) (key range: c.cb= ?:? ) + INDEX SCAN (d.i_b) (key range: ((d.cb= ?:? ) or (d.cb= ?:? ))) + + rewritten query: select /*+ ORDERED USE_HASH */ count(*) from [dba.ta] a, [dba.tb] b, [dba.tc] c, [dba.td] d where a.cd=b.cd and b.cd=c.cd and c.cd=d.cd and ((a.cb= ?:? ) or (a.cb= ?:? ) or (a.cb= ?:? )) and ((b.cb= ?:? ) or (b.cb= ?:? ) or (b.cb= ?:? ) or (b.cb= ?:? )) and ((d.cb= ?:? ) or (d.cb= ?:? )) and c.cb= ?:? + +Trace Statistics: + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: memory) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: memory) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (index: dba.tc.i_b), (btree time: ?, fetch: ?, ioread: ?, readkeys: ?, filteredkeys: ?, rows: ?) (lookup time: ?, rows: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: memory) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (index: dba.ta.i_b), (btree time: ?, fetch: ?, ioread: ?, readkeys: ?, filteredkeys: ?, rows: ?) (lookup time: ?, rows: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (index: dba.tb.i_b), (btree time: ?, fetch: ?, ioread: ?, readkeys: ?, filteredkeys: ?, rows: ?) (lookup time: ?, rows: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (index: dba.td.i_b), (btree time: ?, fetch: ?, ioread: ?, readkeys: ?, filteredkeys: ?, rows: ?) (lookup time: ?, rows: ?) + + +=================================================== +0 +=================================================== + +#### 3. build input: int vs bigint -> int or bigint (page: int == bigint) + +=================================================== +count(*) +2000 + +Query plan: +hash-join (inner join) + edge: term[?] AND term[?] AND term[?] AND term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ USE_HASH */ count(*) from ta a, t_bigint b where a.ca=b.ca and a.cb=b.cb and a.cc=b.cc and a.cd=b.cd +=================================================== +trace + +Query Plan: + HASH JOIN (inner join) + TABLE SCAN (a) + TABLE SCAN (b) + + rewritten query: select /*+ USE_HASH */ count(*) from [dba.ta] a, [dba.t_bigint] b where a.ca=b.ca and a.cb=b.cb and a.cc=b.cc and a.cd=b.cd + +Trace Statistics: + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: memory) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.t_bigint), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.ta), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + + +=================================================== +0 +=================================================== + +#### 4. build input: int vs numeric -> int (page: int < numeric) + +=================================================== +count(*) +2000 + +Query plan: +hash-join (inner join) + edge: term[?] AND term[?] AND term[?] AND term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ USE_HASH */ count(*) from ta a, t_numeric b where a.ca=b.ca and a.cb=b.cb and a.cc=b.cc and a.cd=b.cd +=================================================== +trace + +Query Plan: + HASH JOIN (inner join) + TABLE SCAN (a) + TABLE SCAN (b) + + rewritten query: select /*+ USE_HASH */ count(*) from [dba.ta] a, [dba.t_numeric] b where a.ca=b.ca and a.cb=b.cb and a.cc=b.cc and a.cd=b.cd + +Trace Statistics: + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: memory) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.ta), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.t_numeric), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + + +=================================================== +0 +=================================================== + +#### 5. cost: in_memory, hybrid < file, build_method: in_memory + +=================================================== +0 +=================================================== +count(*) +2000 + +Query plan: +idx-join (inner join) + outer: hash-join (inner join) + edge: term[?] AND term[?] AND term[?] AND term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: iscan + class: c node[?] + index: i_a term[?] AND term[?] AND term[?] + sargs: term[?] + cost: ? card ? + sargs: term[?] + cost: ? card ? +Query stmt: +select /*+ USE_NL(c) USE_HASH(a, b) */ count(*) from ta a, tb b, tc c where a.ca=b.ca and a.cb=b.cb and a.cc=b.cc and a.cd=b.cd and a.ca=c.ca and a.cb=c.cb and a.cc=c.cc and a.cd=c.cd +=================================================== +trace + +Query Plan: + NESTED LOOPS (inner join) + HASH JOIN (inner join) + TABLE SCAN (a) + TABLE SCAN (b) + INDEX SCAN (c.i_a) (key range: a.ca=c.cakey range: a.cb=c.cbkey range: a.cc=c.cc) + + rewritten query: select /*+ USE_NL(c) USE_HASH(a, b) */ count(*) from [dba.ta] a, [dba.tb] b, [dba.tc] c where a.ca=b.ca and a.cb=b.cb and a.cc=b.cc and a.cd=b.cd and a.ca=c.ca and a.cb=c.cb and a.cc=c.cc and a.cd=c.cd + +Trace Statistics: + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + SCAN (index: dba.tc.i_a), (btree time: ?, fetch: ?, ioread: ?, readkeys: ?, filteredkeys: ?, rows: ?) (lookup time: ?, rows: ?) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: memory) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.tb), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.ta), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + + +=================================================== +0 +=================================================== + +#### 6. cost: in_memory, hybrid < file, build_method: hybrid + +=================================================== +0 +=================================================== +count(*) +2000 + +Query plan: +idx-join (inner join) + outer: hash-join (inner join) + edge: term[?] AND term[?] AND term[?] AND term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: iscan + class: c node[?] + index: i_a term[?] AND term[?] AND term[?] + sargs: term[?] + cost: ? card ? + sargs: term[?] + cost: ? card ? +Query stmt: +select /*+ USE_NL(c) USE_HASH(a, b) */ count(*) from ta a, tb b, tc c where a.ca=b.ca and a.cb=b.cb and a.cc=b.cc and a.cd=b.cd and a.ca=c.ca and a.cb=c.cb and a.cc=c.cc and a.cd=c.cd +=================================================== +trace + +Query Plan: + NESTED LOOPS (inner join) + HASH JOIN (inner join) + TABLE SCAN (a) + TABLE SCAN (b) + INDEX SCAN (c.i_a) (key range: a.ca=c.cakey range: a.cb=c.cbkey range: a.cc=c.cc) + + rewritten query: select /*+ USE_NL(c) USE_HASH(a, b) */ count(*) from [dba.ta] a, [dba.tb] b, [dba.tc] c where a.ca=b.ca and a.cb=b.cb and a.cc=b.cc and a.cd=b.cd and a.ca=c.ca and a.cb=c.cb and a.cc=c.cc and a.cd=c.cd + +Trace Statistics: + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + SCAN (index: dba.tc.i_a), (btree time: ?, fetch: ?, ioread: ?, readkeys: ?, filteredkeys: ?, rows: ?) (lookup time: ?, rows: ?) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: hybrid) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.tb), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.ta), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + + +=================================================== +0 +=================================================== + +#### 7. cost: in_memory, hybrid < file, build_method: file + +=================================================== +0 +=================================================== +count(*) +2000 + +Query plan: +idx-join (inner join) + outer: hash-join (inner join) + edge: term[?] AND term[?] AND term[?] AND term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: iscan + class: c node[?] + index: i_a term[?] AND term[?] AND term[?] + sargs: term[?] + cost: ? card ? + sargs: term[?] + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_NL(c) USE_HASH(a, b) */ count(*) from ta a, tb b, tc c where a.ca=b.ca and a.cb=b.cb and a.cc=b.cc and a.cd=b.cd and a.ca=c.ca and a.cb=c.cb and a.cc=c.cc and a.cd=c.cd +=================================================== +trace + +Query Plan: + NESTED LOOPS (inner join) + HASH JOIN (inner join) + TABLE SCAN (a) + TABLE SCAN (b) + INDEX SCAN (c.i_a) (key range: a.ca=c.cakey range: a.cb=c.cbkey range: a.cc=c.cc) + + rewritten query: select /*+ ORDERED USE_NL(c) USE_HASH(a, b) */ count(*) from [dba.ta] a, [dba.tb] b, [dba.tc] c where a.ca=b.ca and a.cb=b.cb and a.cc=b.cc and a.cd=b.cd and a.ca=c.ca and a.cb=c.cb and a.cc=c.cc and a.cd=c.cd + +Trace Statistics: + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + SCAN (index: dba.tc.i_a), (btree time: ?, fetch: ?, ioread: ?, readkeys: ?, filteredkeys: ?, rows: ?) (lookup time: ?, rows: ?) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: file) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.tb), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.ta), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + + +=================================================== +count(*) +2000 + +Query plan: +hash-join (inner join) + edge: term[?] AND term[?] AND term[?] AND term[?] + outer: idx-join (inner join) + outer: sscan + class: a node[?] + cost: ? card ? + inner: iscan + class: c node[?] + index: i_a term[?] AND term[?] AND term[?] + sargs: term[?] + cost: ? card ? + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ USE_NL(c) USE_HASH(a, b) */ count(*) from ta a, tb b, tc c where a.ca=b.ca and a.cb=b.cb and a.cc=b.cc and a.cd=b.cd and a.ca=c.ca and a.cb=c.cb and a.cc=c.cc and a.cd=c.cd +=================================================== +trace + +Query Plan: + HASH JOIN (inner join) + NESTED LOOPS (inner join) + TABLE SCAN (a) + INDEX SCAN (c.i_a) (key range: a.ca=c.cakey range: a.cb=c.cbkey range: a.cc=c.cc) + TABLE SCAN (b) + + rewritten query: select /*+ USE_NL(c) USE_HASH(a, b) */ count(*) from [dba.ta] a, [dba.tb] b, [dba.tc] c where a.ca=b.ca and a.cb=b.cb and a.cc=b.cc and a.cd=b.cd and a.ca=c.ca and a.cb=c.cb and a.cc=c.cc and a.cd=c.cd + +Trace Statistics: + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: file) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.tb), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.ta), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + SCAN (index: dba.tc.i_a), (btree time: ?, fetch: ?, ioread: ?, readkeys: ?, filteredkeys: ?, rows: ?) (lookup time: ?, rows: ?) + + +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +0 diff --git a/sql/_35_fig_cake/cbrd_25382/answers/cbrd_25382_2.answer b/sql/_35_fig_cake/cbrd_25382/answers/cbrd_25382_2.answer new file mode 100755 index 0000000000..78123cff9d --- /dev/null +++ b/sql/_35_fig_cake/cbrd_25382/answers/cbrd_25382_2.answer @@ -0,0 +1,1057 @@ +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +8 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== + +#### 1. hint: recompile ordered use_hash + +=================================================== +4 +=================================================== +12 +Query plan: +hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH */ d,class d,c,class c,b,class b from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_ca c_ca d_ca +1 1 null null null +2 1 null null null +3 1 null null null +4 1 null null null +5 null 5 5 5 +6 null 6 6 6 +7 null 7 7 7 +8 null 8 8 8 + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 2. hint: recompile ordered use_hash(a) + +=================================================== +1 +=================================================== +3 +Query plan: +nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH(a) */ d,class d,c,class c,b,class b from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_ca c_ca d_ca +1 1 null null null +2 null 2 2 2 +3 null 3 3 3 +4 null 4 4 4 +5 null 5 5 5 +6 null 6 6 6 +7 null 7 7 7 +8 null 8 8 8 + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 3. hint: recompile ordered use_hash(b) + +=================================================== +1 +=================================================== +3 +Query plan: +nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH(b) */ d,class d,c,class c,b,class b from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_ca c_ca d_ca +1 null 1 1 1 +2 1 null null null +3 null 3 3 3 +4 null 4 4 4 +5 null 5 5 5 +6 null 6 6 6 +7 null 7 7 7 +8 null 8 8 8 + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 4. hint: recompile ordered use_hash(c) + +=================================================== +1 +=================================================== +3 +Query plan: +nl-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH(c) */ d,class d,c,class c,b,class b from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_ca c_ca d_ca +1 null 1 1 1 +2 null 2 2 2 +3 1 null null null +4 null 4 4 4 +5 null 5 5 5 +6 null 6 6 6 +7 null 7 7 7 +8 null 8 8 8 + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 5. hint: recompile ordered use_hash(d) + +=================================================== +1 +=================================================== +3 +Query plan: +hash-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH(d) */ d,class d,c,class c,b,class b from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_ca c_ca d_ca +1 null 1 1 1 +2 null 2 2 2 +3 null 3 3 3 +4 1 null null null +5 null 5 5 5 +6 null 6 6 6 +7 null 7 7 7 +8 null 8 8 8 + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 6. hint: recompile ordered use_hash no_use_hash + +=================================================== +8 +=================================================== +24 +Query plan: +nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH USE_HASH */ d,class d,c,class c,b,class b from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_ca c_ca d_ca +1 1 null null null +2 1 null null null +3 1 null null null +4 1 null null null +5 1 null null null +6 1 null null null +7 1 null null null +8 1 null null null + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 7. hint: recompile ordered use_hash no_use_hash(a) + +=================================================== +5 +=================================================== +15 +Query plan: +hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(a) USE_HASH */ d,class d,c,class c,b,class b from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_ca c_ca d_ca +1 1 null null null +2 1 null null null +3 1 null null null +4 1 null null null +5 1 null null null +6 null 6 6 6 +7 null 7 7 7 +8 null 8 8 8 + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 8. hint: recompile ordered use_hash no_use_hash(b) + +=================================================== +5 +=================================================== +15 +Query plan: +hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(b) USE_HASH */ d,class d,c,class c,b,class b from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_ca c_ca d_ca +1 1 null null null +2 1 null null null +3 1 null null null +4 1 null null null +5 null 5 5 5 +6 1 null null null +7 null 7 7 7 +8 null 8 8 8 + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 9. hint: recompile ordered use_hash no_use_hash(c) + +=================================================== +5 +=================================================== +15 +Query plan: +hash-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(c) USE_HASH */ d,class d,c,class c,b,class b from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_ca c_ca d_ca +1 1 null null null +2 1 null null null +3 1 null null null +4 1 null null null +5 null 5 5 5 +6 null 6 6 6 +7 1 null null null +8 null 8 8 8 + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 10. hint: recompile ordered use_hash no_use_hash(d) + +=================================================== +5 +=================================================== +15 +Query plan: +nl-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(d) USE_HASH */ d,class d,c,class c,b,class b from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_ca c_ca d_ca +1 1 null null null +2 1 null null null +3 1 null null null +4 1 null null null +5 null 5 5 5 +6 null 6 6 6 +7 null 7 7 7 +8 1 null null null + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 11. hint: recompile ordered use_hash(a,b) no_use_hash(c,d) + +=================================================== +4 +=================================================== +12 +Query plan: +nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(c, d) USE_HASH(a, b) */ d,class d,c,class c,b,class b from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_ca c_ca d_ca +1 1 null null null +2 1 null null null +3 null 3 3 3 +4 null 4 4 4 +5 null 5 5 5 +6 null 6 6 6 +7 1 null null null +8 1 null null null + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 12. hint: recompile ordered use_hash(a,c) no_use_hash(b,d) + +=================================================== +4 +=================================================== +12 +Query plan: +nl-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(b, d) USE_HASH(a, c) */ d,class d,c,class c,b,class b from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_ca c_ca d_ca +1 1 null null null +2 null 2 2 2 +3 1 null null null +4 null 4 4 4 +5 null 5 5 5 +6 1 null null null +7 null 7 7 7 +8 1 null null null + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 13. hint: recompile ordered use_hash(a,b,c) no_use_hash(b,d) + +=================================================== +5 +=================================================== +15 +Query plan: +nl-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(b, d) USE_HASH(a, b, c) */ d,class d,c,class c,b,class b from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_ca c_ca d_ca +1 1 null null null +2 1 null null null +3 1 null null null +4 null 4 4 4 +5 null 5 5 5 +6 1 null null null +7 null 7 7 7 +8 1 null null null + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 14. hint: recompile ordered use_hash(b,c,d) no_use_hash(b,c,d) + +=================================================== +6 +=================================================== +18 +Query plan: +nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(b, c, d) USE_HASH(b, c, d) */ d,class d,c,class c,b,class b from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_ca c_ca d_ca +1 null 1 1 1 +2 1 null null null +3 1 null null null +4 1 null null null +5 null 5 5 5 +6 1 null null null +7 1 null null null +8 1 null null null + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 15. hint: recompile use_hash + +=================================================== +4 +=================================================== +16 +Query plan: +nl-join (cross join) + outer: hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ USE_HASH */ d,class d,c,class c,b,class b from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_ca c_ca d_ca +1 1 null null null +2 1 null null null +3 1 null null null +4 1 null null null +5 null 5 5 null +6 null 6 6 null +7 null 7 7 null +8 null 8 8 null + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 16. hint: recompile use_hash(a,b,c) -> split(d) + +=================================================== +3 +=================================================== +14 +Query plan: +hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ USE_HASH(a, b, c) */ c,class c,b,class b from ta a, tb b, tc c where a.ca=b.ca and b.ca=c.ca and a.flag= ?:? +Query plan: +sscan + class: d node[?] + cost: ? card ? +Query stmt: +select /*+ USE_HASH */ d,class d from td d +=================================================== +a_ca a_flag b_ca c_ca d_ca +1 1 null null null +2 1 null null null +3 1 null null null +4 null 4 4 null +5 null 5 5 null +6 null 6 6 null +7 null 7 7 null +8 null 8 8 null + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 17. hint: recompile no_use_hash + +=================================================== +4 +=================================================== +20 +Query plan: +nl-join (cross join) + outer: nl-join (cross join) + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ NO_USE_HASH */ d,class d,c,class c,b,class b from ta a, tb b, tc c, td d where a.ca=b.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_ca c_ca d_ca +1 null 1 null null +2 null 2 null null +3 null 3 null null +4 null 4 null null +5 1 null null null +6 1 null null null +7 1 null null null +8 1 null null null + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 18. hint: recompile no_use_hash(a,b) -> split(c,d) + +=================================================== +2 +=================================================== +18 +Query plan: +nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ NO_USE_HASH(a, b) */ b,class b from ta a, tb b where a.ca=b.ca and a.flag= ?:? +Query plan: +sscan + class: c node[?] + cost: ? card ? +Query stmt: +select /*+ NO_USE_HASH */ c,class c from tc c +Query plan: +sscan + class: d node[?] + cost: ? card ? +Query stmt: +select /*+ NO_USE_HASH */ d,class d from td d +=================================================== +a_ca a_flag b_ca c_ca d_ca +1 null 1 null null +2 null 2 null null +3 null 3 null null +4 null 4 null null +5 1 null null null +6 1 null null null +7 null 7 null null +8 null 8 null null + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 19. hint: recompile use_hash(a,c) no_use_hash(b) -> split(d) + +=================================================== +3 +=================================================== +19 +Query plan: +nl-join (cross join) + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: b node[?] + cost: ? card ? + inner: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ NO_USE_HASH(b) USE_HASH(a, c) */ c,class c,b,class b from ta a, tb b, tc c where a.ca=b.ca and a.flag= ?:? +Query plan: +sscan + class: d node[?] + cost: ? card ? +Query stmt: +select /*+ NO_USE_HASH USE_HASH */ d,class d from td d +=================================================== +a_ca a_flag b_ca c_ca d_ca +1 1 null null null +2 null 2 null null +3 1 null null null +4 null 4 null null +5 null 5 null null +6 1 null null null +7 null 7 null null +8 null 8 null null + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 20. hint: recompile use_hash(a,b) + +=================================================== +2 +=================================================== +18 +Query plan: +nl-join (cross join) + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: temp + order: UNORDERED + subplan: nl-join (inner join) + edge: term[?] + outer: sscan + class: c node[?] + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ USE_HASH(a, b) */ d,class d,c,class c,b,class b from ta a, tb b, tc c, td d where a.ca=b.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_ca c_ca d_ca +1 1 null null null +2 1 null null null +3 null 3 null null +4 null 4 null null +5 null 5 null null +6 null 6 null null +7 null 7 null null +8 null 8 null null + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 21. hint: recompile use_hash(a,b,c) + +=================================================== +3 +=================================================== +7 +Query plan: +nl-join (cross join) + outer: hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ USE_HASH(a, b, c) */ d,class d,c,class c,b,class b from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and a.flag= ?:? and d.ca= ?:? +=================================================== +a_ca a_flag b_ca c_ca d_ca +1 1 null null 1 +2 1 null null 2 +3 1 null null 3 +4 null 4 4 4 +5 null 5 5 5 +6 null 6 6 6 +7 null 7 7 7 +8 null 8 8 null + +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +0 diff --git a/sql/_35_fig_cake/cbrd_25382/answers/cbrd_25382_3.answer b/sql/_35_fig_cake/cbrd_25382/answers/cbrd_25382_3.answer new file mode 100755 index 0000000000..2d226aabb4 --- /dev/null +++ b/sql/_35_fig_cake/cbrd_25382/answers/cbrd_25382_3.answer @@ -0,0 +1,481 @@ +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +4 +=================================================== +4 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== + +#### 1. left outer join (ansi) #### + +=================================================== +a_ca b_ca c_ca d_ca +1 1 1 1 +2 null null null +3 3 null null +4 4 4 null + +Query plan: +temp(order by) + subplan: hash-join (left outer join) + edge: term[?] + outer: hash-join (left outer join) + edge: term[?] + outer: hash-join (left outer join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH */ a.ca, b.ca, c.ca, d.ca from ta a left outer join tb b on b.flag= ?:? and b.ca=a.ca left outer join tc c on c.flag= ?:? and c.ca=b.ca left outer join td d on d.flag= ?:? and d.ca=c.ca where a.flag= ?:? order by ? +=================================================== +0 +=================================================== + +#### 2. left outer join (non-ansi) + +=================================================== +a_ca b_ca c_ca d_ca +1 1 1 1 +2 null null null +3 3 null null +4 4 4 null + +Query plan: +temp(order by) + subplan: hash-join (left outer join) + edge: term[?] + outer: hash-join (left outer join) + edge: term[?] + outer: hash-join (left outer join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH */ a.ca, b.ca, c.ca, d.ca from ta a left outer join tb b on b.flag= ?:? and a.ca=b.ca left outer join tc c on c.flag= ?:? and b.ca=c.ca left outer join td d on d.flag= ?:? and c.ca=d.ca where a.flag= ?:? order by ? +=================================================== +0 +=================================================== + +#### 3. left outer join + during join terms + +=================================================== +a_ca b_ca c_ca d_ca +1 1 1 1 +2 null null null +3 3 null null +4 4 4 null + +Query plan: +temp(order by) + subplan: hash-join (left outer join) + edge: term[?] + outer: hash-join (left outer join) + edge: term[?] + outer: hash-join (left outer join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + during:term[?] + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + during:term[?] + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH */ a.ca, b.ca, c.ca, d.ca, a.flag from ta a left outer join tb b on b.flag= ?:? and b.ca=a.ca left outer join tc c on c.flag= ?:? and b.flag= ?:? and c.ca=b.ca left outer join td d on d.flag= ?:? and c.flag= ?:? and d.ca=c.ca where a.flag= ?:? order by ? +=================================================== +0 +=================================================== + +#### 4. left outer join (ansi) + after join terms + +=================================================== +a_ca b_ca c_ca d_ca +1 1 1 1 +2 null null null +3 3 null null +4 4 4 null + +Query plan: +temp(order by) + subplan: hash-join (left outer join) + edge: term[?] + outer: hash-join (left outer join) + edge: term[?] + outer: hash-join (left outer join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + cost: ? card ? + after: term[?] AND term[?] AND term[?] + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH */ a.ca, b.ca, c.ca, d.ca from ta a left outer join tb b on b.ca=a.ca left outer join tc c on c.ca=b.ca left outer join td d on d.ca=c.ca where nvl(b.flag, ?)=? and nvl(c.flag, ?)=? and nvl(d.flag, ?)=? and a.flag= ?:? order by ? +=================================================== +0 +=================================================== + +#### 5. left outer join (non-ansi) + after join terms + +=================================================== +a_ca b_ca c_ca d_ca +1 1 1 1 +2 null null null +3 3 null null +4 4 4 null + +Query plan: +temp(order by) + subplan: hash-join (left outer join) + edge: term[?] + outer: hash-join (left outer join) + edge: term[?] + outer: hash-join (left outer join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + cost: ? card ? + after: term[?] AND term[?] AND term[?] + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH */ a.ca, b.ca, c.ca, d.ca from ta a left outer join tb b on a.ca=b.ca left outer join tc c on b.ca=c.ca left outer join td d on c.ca=d.ca where nvl(b.flag, ?)=? and nvl(c.flag, ?)=? and nvl(d.flag, ?)=? and a.flag= ?:? order by ? +=================================================== +0 +=================================================== + +#### 6. right outer join (ansi) + +=================================================== +d_ca d_flag c_ca c_flag b_ca b_flag a_ca +1 0 1 0 1 0 1 +1 1 1 0 1 0 1 +1 0 1 1 1 0 1 +1 1 1 1 1 0 1 +1 0 1 0 1 1 1 +1 1 1 0 1 1 1 +1 0 1 1 1 1 1 +1 1 1 1 1 1 1 +null null null null null null 2 +null null null null 3 0 3 +null null null null 3 1 3 +null null 4 0 4 0 4 +null null 4 1 4 0 4 +null null 4 0 4 1 4 +null null 4 1 4 1 4 + +Query plan: +temp(order by) + subplan: hash-join (right outer join) + edge: term[?] + outer: hash-join (right outer join) + edge: term[?] + outer: hash-join (right outer join) + edge: term[?] + outer: sscan + class: d node[?] + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + sort: ? asc, ? asc, ? asc, ? asc, ? asc, ? asc, ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH */ d.ca, d.flag, c.ca, c.flag, b.ca, b.flag, a.ca from td d right outer join tc c on c.ca=d.ca right outer join tb b on b.ca=c.ca right outer join ta a on a.ca=b.ca where a.flag= ?:? order by ?, ?, ?, ?, ?, ?, ? +=================================================== +0 +=================================================== + +#### 7. right outer join (non-ansi) + +=================================================== +d_ca d_flag c_ca c_flag b_ca b_flag a_ca +1 0 1 0 1 0 1 +1 1 1 0 1 0 1 +1 0 1 1 1 0 1 +1 1 1 1 1 0 1 +1 0 1 0 1 1 1 +1 1 1 0 1 1 1 +1 0 1 1 1 1 1 +1 1 1 1 1 1 1 +null null null null null null 2 +null null null null 3 0 3 +null null null null 3 1 3 +null null 4 0 4 0 4 +null null 4 1 4 0 4 +null null 4 0 4 1 4 +null null 4 1 4 1 4 + +Query plan: +temp(order by) + subplan: hash-join (right outer join) + edge: term[?] + outer: hash-join (right outer join) + edge: term[?] + outer: hash-join (right outer join) + edge: term[?] + outer: sscan + class: d node[?] + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + sort: ? asc, ? asc, ? asc, ? asc, ? asc, ? asc, ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH */ d.ca, d.flag, c.ca, c.flag, b.ca, b.flag, a.ca from td d right outer join tc c on d.ca=c.ca right outer join tb b on c.ca=b.ca right outer join ta a on b.ca=a.ca where a.flag= ?:? order by ?, ?, ?, ?, ?, ?, ? +=================================================== +0 +=================================================== + +#### 8. right outer join + during join terms + +=================================================== +d_ca d_flag c_ca c_flag b_ca b_flag a_ca a_flag +null null null null null null 1 0 +null null null null null null 2 0 +null null null null null null 3 0 +null null null null null null 4 0 +null null null null 1 0 1 1 +null null 1 0 1 1 1 1 +1 0 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 +null null null null null null 2 1 +null null null null 3 0 3 1 +null null null null 3 1 3 1 +null null null null 4 0 4 1 +null null 4 0 4 1 4 1 +null null 4 1 4 1 4 1 + +Query plan: +temp(order by) + subplan: hash-join (right outer join) + edge: term[?] + outer: hash-join (right outer join) + edge: term[?] + outer: hash-join (right outer join) + edge: term[?] + outer: sscan + class: d node[?] + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + during:term[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + during:term[?] + cost: ? card ? + inner: sscan + class: a node[?] + cost: ? card ? + during:term[?] + cost: ? card ? + sort: ? asc, ? asc, ? asc, ? asc, ? asc, ? asc, ? asc, ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH */ d.ca, d.flag, c.ca, c.flag, b.ca, b.flag, a.ca, a.flag from td d right outer join tc c on c.flag= ?:? and c.ca=d.ca right outer join tb b on b.flag= ?:? and b.ca=c.ca right outer join ta a on a.flag= ?:? and a.ca=b.ca order by ?, ?, ?, ?, ?, ?, ?, ? +=================================================== +0 +=================================================== + +#### 9. right outer join (ansi) + after join terms + +=================================================== +d_ca c_ca b_ca a_ca +1 1 1 1 +null null null 2 +null null 3 3 +null 4 4 4 + +Query plan: +temp(order by) + subplan: hash-join (right outer join) + edge: term[?] + outer: hash-join (right outer join) + edge: term[?] + outer: hash-join (right outer join) + edge: term[?] + outer: sscan + class: d node[?] + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + after: term[?] AND term[?] AND term[?] + cost: ? card ? + sort: ? asc, ? asc, ? asc, ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH */ d.ca, c.ca, b.ca, a.ca from td d right outer join tc c on c.ca=d.ca right outer join tb b on b.ca=c.ca right outer join ta a on a.ca=b.ca where nvl(d.flag, ?)=? and nvl(c.flag, ?)=? and nvl(b.flag, ?)=? and a.flag= ?:? order by ?, ?, ?, ? +=================================================== +0 +=================================================== + +#### 10. right outer join (non-ansi) + after join terms + +=================================================== +d_ca c_ca b_ca a_ca +1 1 1 1 +null null null 2 +null null 3 3 +null 4 4 4 + +Query plan: +temp(order by) + subplan: hash-join (right outer join) + edge: term[?] + outer: hash-join (right outer join) + edge: term[?] + outer: hash-join (right outer join) + edge: term[?] + outer: sscan + class: d node[?] + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + after: term[?] AND term[?] AND term[?] + cost: ? card ? + sort: ? asc, ? asc, ? asc, ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH */ d.ca, c.ca, b.ca, a.ca from td d right outer join tc c on d.ca=c.ca right outer join tb b on c.ca=b.ca right outer join ta a on b.ca=a.ca where nvl(d.flag, ?)=? and nvl(c.flag, ?)=? and nvl(b.flag, ?)=? and a.flag= ?:? order by ?, ?, ?, ? +=================================================== +0 +=================================================== +0 diff --git a/sql/_35_fig_cake/cbrd_25382/answers/cbrd_25382_4.answer b/sql/_35_fig_cake/cbrd_25382/answers/cbrd_25382_4.answer new file mode 100755 index 0000000000..febd5a8f1d --- /dev/null +++ b/sql/_35_fig_cake/cbrd_25382/answers/cbrd_25382_4.answer @@ -0,0 +1,604 @@ +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +4 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== + +#### 1. hint: recompile ordered use_hash + +=================================================== +a_ca b_ca c_ca d_ca +1 1 1 1 +2 2 2 2 +3 3 3 3 +4 4 4 4 + +Query plan: +temp(order by) + subplan: hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH */ a.ca, b.ca, c.ca, d.ca from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca order by ? +=================================================== +0 +=================================================== + +#### 2. hint: recompile ordered use_hash(a) + +=================================================== +a_ca b_ca c_ca d_ca +1 1 1 1 +2 2 2 2 +3 3 3 3 +4 4 4 4 + +Query plan: +temp(order by) + subplan: nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH(a) */ a.ca, b.ca, c.ca, d.ca from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca order by ? +=================================================== +0 +=================================================== + +#### 3. hint: recompile ordered use_hash(b) + +=================================================== +a_ca b_ca c_ca d_ca +1 1 1 1 +2 2 2 2 +3 3 3 3 +4 4 4 4 + +Query plan: +temp(order by) + subplan: nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH(b) */ a.ca, b.ca, c.ca, d.ca from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca order by ? +=================================================== +0 +=================================================== + +#### 4. hint: recompile ordered use_hash(c) + +=================================================== +a_ca b_ca c_ca d_ca +1 1 1 1 +2 2 2 2 +3 3 3 3 +4 4 4 4 + +Query plan: +temp(order by) + subplan: nl-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH(c) */ a.ca, b.ca, c.ca, d.ca from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca order by ? +=================================================== +0 +=================================================== + +#### 5. hint: recompile ordered use_hash(d) + +=================================================== +a_ca b_ca c_ca d_ca +1 1 1 1 +2 2 2 2 +3 3 3 3 +4 4 4 4 + +Query plan: +temp(order by) + subplan: hash-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH(d) */ a.ca, b.ca, c.ca, d.ca from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca order by ? +=================================================== +0 +=================================================== + +#### 6. hint: recompile ordered use_hash no_use_hash + +=================================================== +a_ca b_ca c_ca d_ca +1 1 1 1 +2 2 2 2 +3 3 3 3 +4 4 4 4 + +Query plan: +temp(order by) + subplan: nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH USE_HASH */ a.ca, b.ca, c.ca, d.ca from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca order by ? +=================================================== +0 +=================================================== + +#### 7. hint: recompile ordered use_hash no_use_hash(a) + +=================================================== +a_ca b_ca c_ca d_ca +1 1 1 1 +2 2 2 2 +3 3 3 3 +4 4 4 4 + +Query plan: +temp(order by) + subplan: hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(a) USE_HASH */ a.ca, b.ca, c.ca, d.ca from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca order by ? +=================================================== +0 +=================================================== + +#### 8. hint: recompile ordered use_hash no_use_hash(b) + +=================================================== +a_ca b_ca c_ca d_ca +1 1 1 1 +2 2 2 2 +3 3 3 3 +4 4 4 4 + +Query plan: +temp(order by) + subplan: hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(b) USE_HASH */ a.ca, b.ca, c.ca, d.ca from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca order by ? +=================================================== +0 +=================================================== + +#### 9. hint: recompile ordered use_hash no_use_hash(c) + +=================================================== +a_ca b_ca c_ca d_ca +1 1 1 1 +2 2 2 2 +3 3 3 3 +4 4 4 4 + +Query plan: +temp(order by) + subplan: hash-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(c) USE_HASH */ a.ca, b.ca, c.ca, d.ca from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca order by ? +=================================================== +0 +=================================================== + +#### 10. hint: recompile ordered use_hash no_use_hash(d) + +=================================================== +a_ca b_ca c_ca d_ca +1 1 1 1 +2 2 2 2 +3 3 3 3 +4 4 4 4 + +Query plan: +temp(order by) + subplan: nl-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(d) USE_HASH */ a.ca, b.ca, c.ca, d.ca from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca order by ? +=================================================== +0 +=================================================== + +#### 11. hint: recompile ordered use_hash(a,b) no_use_hash(c,d) + +=================================================== +a_ca b_ca c_ca d_ca +1 1 1 1 +2 2 2 2 +3 3 3 3 +4 4 4 4 + +Query plan: +temp(order by) + subplan: nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(c, d) USE_HASH(a, b) */ a.ca, b.ca, c.ca, d.ca from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca order by ? +=================================================== +0 +=================================================== + +#### 12. hint: recompile ordered use_hash(a,c) no_use_hash(b,d) + +=================================================== +a_ca b_ca c_ca d_ca +1 1 1 1 +2 2 2 2 +3 3 3 3 +4 4 4 4 + +Query plan: +temp(order by) + subplan: nl-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(b, d) USE_HASH(a, c) */ a.ca, b.ca, c.ca, d.ca from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca order by ? +=================================================== +0 +=================================================== + +#### 13. hint: recompile ordered use_hash(a,b,c) no_use_hash(b,d) + +=================================================== +a_ca b_ca c_ca d_ca +1 1 1 1 +2 2 2 2 +3 3 3 3 +4 4 4 4 + +Query plan: +temp(order by) + subplan: nl-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(b, d) USE_HASH(a, b, c) */ a.ca, b.ca, c.ca, d.ca from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca order by ? +=================================================== +0 +=================================================== + +#### 14. hint: recompile ordered use_hash(b,c,d) no_use_hash(b,c,d) + +=================================================== +a_ca b_ca c_ca d_ca +1 1 1 1 +2 2 2 2 +3 3 3 3 +4 4 4 4 + +Query plan: +temp(order by) + subplan: nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(b, c, d) USE_HASH(b, c, d) */ a.ca, b.ca, c.ca, d.ca from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca order by ? +=================================================== +0 +=================================================== +0 diff --git a/sql/_35_fig_cake/cbrd_25382/answers/cbrd_25382_5.answer b/sql/_35_fig_cake/cbrd_25382/answers/cbrd_25382_5.answer new file mode 100755 index 0000000000..2e4308f1c0 --- /dev/null +++ b/sql/_35_fig_cake/cbrd_25382/answers/cbrd_25382_5.answer @@ -0,0 +1,686 @@ +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +2000 +=================================================== +2000 +=================================================== +2000 +=================================================== +2000 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== + +#### 1. empty outer + +=================================================== +a_cd b_cd + +Query plan: +temp(order by) + subplan: hash-join (inner join) + edge: term[?] + outer: iscan + class: a node[?] + index: i_a term[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH */ a.cd, b.cd from ta a, tb b where a.cd=b.cd and a.ca= ?:? order by ? +=================================================== +trace + +Query Plan: + SORT (order by) + HASH JOIN (inner join) + INDEX SCAN (a.i_a) (key range: a.ca= ?:? ) + TABLE SCAN (b) + + rewritten query: select /*+ ORDERED USE_HASH */ a.cd, b.cd from [dba.ta] a, [dba.tb] b where a.cd=b.cd and a.ca= ?:? order by ? + +Trace Statistics: + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: skip) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.tb), (noscan time: ?, fetch: ?, ioread: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (index: dba.ta.i_a), (btree time: ?, fetch: ?, ioread: ?, readkeys: ?, filteredkeys: ?, rows: ?) (lookup time: ?, rows: ?) + + +=================================================== +0 +=================================================== + +#### 2. empty inner + +=================================================== +a_cd b_cd + +Query plan: +temp(order by) + subplan: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: iscan + class: b node[?] + index: i_a term[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH */ a.cd, b.cd from ta a, tb b where a.cd=b.cd and b.ca= ?:? order by ? +=================================================== +trace + +Query Plan: + SORT (order by) + HASH JOIN (inner join) + TABLE SCAN (a) + INDEX SCAN (b.i_a) (key range: b.ca= ?:? ) + + rewritten query: select /*+ ORDERED USE_HASH */ a.cd, b.cd from [dba.ta] a, [dba.tb] b where a.cd=b.cd and b.ca= ?:? order by ? + +Trace Statistics: + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: skip) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (index: dba.tb.i_a), (btree time: ?, fetch: ?, ioread: ?, readkeys: ?, filteredkeys: ?, rows: ?) (lookup time: ?, rows: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.ta), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + + +=================================================== +0 +=================================================== + +#### 3. empty inner + left outer join + +=================================================== +a_cd b_cd +2000 null + +Query plan: +temp(order by) + subplan: hash-join (left outer join) + edge: term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: iscan + class: b node[?] + index: i_a term[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH */ a.cd, b.cd from ta a left outer join tb b on b.ca= ?:? and b.cd=a.cd order by ? for orderby_num()> ?:? and orderby_num()<= ?:? +=================================================== +trace + +Query Plan: + SORT (order by) + HASH JOIN (left outer join) + TABLE SCAN (a) + INDEX SCAN (b.i_a) (key range: b.ca= ?:? ) + + rewritten query: select /*+ ORDERED USE_HASH */ a.cd, b.cd from [dba.ta] a left outer join [dba.tb] b on b.ca= ?:? and b.cd=a.cd order by ? for orderby_num()> ?:? and orderby_num()<= ?:? + +Trace Statistics: + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + ORDERBY (time: ?, topnsort: true) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: skip) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (index: dba.tb.i_a), (btree time: ?, fetch: ?, ioread: ?, readkeys: ?, filteredkeys: ?, rows: ?) (lookup time: ?, rows: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.ta), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + + +=================================================== +0 +=================================================== + +#### 4. multiple tables + +=================================================== +a_cd b_cd c_cd d_cd +1 1 1 1 +1001 1001 1001 1001 + +Query plan: +temp(order by) + subplan: hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ USE_HASH */ a.cd, b.cd, c.cd, d.cd from ta a, tb b, tc c, td d where a.cd=b.cd and b.cd=c.cd and c.cd=d.cd and d.cc= ?:? and c.cc= ?:? and b.cc= ?:? and a.cc= ?:? order by ? +=================================================== +trace + +Query Plan: + SORT (order by) + HASH JOIN (inner join) + HASH JOIN (inner join) + HASH JOIN (inner join) + TABLE SCAN (a) + TABLE SCAN (b) + TABLE SCAN (c) + TABLE SCAN (d) + + rewritten query: select /*+ USE_HASH */ a.cd, b.cd, c.cd, d.cd from [dba.ta] a, [dba.tb] b, [dba.tc] c, [dba.td] d where a.cd=b.cd and b.cd=c.cd and c.cd=d.cd and d.cc= ?:? and c.cc= ?:? and b.cc= ?:? and a.cc= ?:? order by ? + +Trace Statistics: + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + ORDERBY (time: ?, sort: true, page: ?, ioread: ?) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: memory) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.td), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: memory) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.tc), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: memory) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.tb), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.ta), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + + +=================================================== +0 +=================================================== + +#### 5. inline views + +=================================================== +a_cd b_cd +2 2 +1002 1002 + +Query plan: +sscan + class: ta node[?] + sargs: term[?] + cost: ? card ? +Query stmt: +(select /*+ NO_MERGE */ ta.ca, ta.cb, ta.cc, ta.cd from ta ta where ta.cc= ?:? ) +Query plan: +sscan + class: tb node[?] + sargs: term[?] + cost: ? card ? +Query stmt: +(select /*+ NO_MERGE */ tb.ca, tb.cb, tb.cc, tb.cd from tb tb where tb.cc= ?:? ) +Query plan: +temp(order by) + subplan: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ USE_HASH */ a.cd, b.cd from (select /*+ NO_MERGE */ ta.ca, ta.cb, ta.cc, ta.cd from ta ta where ta.cc= ?:? ) a (ca, cb, cc, cd), (select /*+ NO_MERGE */ tb.ca, tb.cb, tb.cc, tb.cd from tb tb where tb.cc= ?:? ) b (ca, cb, cc, cd) where a.cd=b.cd order by ? +=================================================== +trace + +Query Plan: + TABLE SCAN (dba.ta) + + rewritten query: (select /*+ NO_MERGE */ [dba.ta].ca, [dba.ta].cb, [dba.ta].cc, [dba.ta].cd from [dba.ta] [dba.ta] where [dba.ta].cc= ?:? ) + + TABLE SCAN (dba.tb) + + rewritten query: (select /*+ NO_MERGE */ [dba.tb].ca, [dba.tb].cb, [dba.tb].cc, [dba.tb].cd from [dba.tb] [dba.tb] where [dba.tb].cc= ?:? ) + + SORT (order by) + HASH JOIN (inner join) + TABLE SCAN (a) + TABLE SCAN (b) + + rewritten query: select /*+ USE_HASH */ a.cd, b.cd from (select /*+ NO_MERGE */ [dba.ta].ca, [dba.ta].cb, [dba.ta].cc, [dba.ta].cd from [dba.ta] [dba.ta] where [dba.ta].cc= ?:? ) a (ca, cb, cc, cd), (select /*+ NO_MERGE */ [dba.tb].ca, [dba.tb].cb, [dba.tb].cc, [dba.tb].cd from [dba.tb] [dba.tb] where [dba.tb].cc= ?:? ) b (ca, cb, cc, cd) where a.cd=b.cd order by ? + + +Trace Statistics: + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + ORDERBY (time: ?, sort: true, page: ?, ioread: ?) + SUBQUERY (uncorrelated) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.ta), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.tb), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: memory) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + + +=================================================== +0 +=================================================== + +#### 6. subqueries + +=================================================== +a_cd b_cd d_cd +3 3 3 +1003 1003 1003 + +Query plan: +iscan + class: d node[?] + index: i_c term[?] (covers) + filtr: term[?] + cost: ? card ? +Query stmt: +(select /*+ NO_SUBQUERY_CACHE */ d.cd from td d where d.cd=b.cd and d.cd=b.cd) +Query plan: +sscan + class: ta node[?] + sargs: term[?] + cost: ? card ? +Query stmt: +(select /*+ NO_MERGE */ ta.ca, ta.cb, ta.cc, ta.cd from ta ta where ta.cc= ?:? ) +Query plan: +sscan + class: tb node[?] + sargs: term[?] + cost: ? card ? +Query stmt: +(select /*+ NO_MERGE */ tb.ca, tb.cb, tb.cc, tb.cd from tb tb where tb.cc= ?:? ) +Query plan: +temp(distinct) + subplan: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? +Query stmt: +(select distinct c.ca from tc c) +Query plan: +temp(order by) + subplan: hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: av? node[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ USE_HASH */ a.cd, b.cd, (select /*+ NO_SUBQUERY_CACHE */ d.cd from td d where d.cd=b.cd and d.cd=b.cd) from (select /*+ NO_MERGE */ ta.ca, ta.cb, ta.cc, ta.cd from ta ta where ta.cc= ?:? ) a (ca, cb, cc, cd), (select /*+ NO_MERGE */ tb.ca, tb.cb, tb.cc, tb.cd from tb tb where tb.cc= ?:? ) b (ca, cb, cc, cd), (select distinct c.ca from tc c) av? (av_?) where a.cd=b.cd and a.ca=av?.av_? order by ? +=================================================== +trace + +Query Plan: + INDEX SCAN (d.i_c) (key range: d.cd=b.cd, key filter: d.cd=b.cd, covered: true) + + rewritten query: (select /*+ NO_SUBQUERY_CACHE */ d.cd from [dba.td] d where d.cd=b.cd and d.cd=b.cd) + + TABLE SCAN (dba.ta) + + rewritten query: (select /*+ NO_MERGE */ [dba.ta].ca, [dba.ta].cb, [dba.ta].cc, [dba.ta].cd from [dba.ta] [dba.ta] where [dba.ta].cc= ?:? ) + + TABLE SCAN (dba.tb) + + rewritten query: (select /*+ NO_MERGE */ [dba.tb].ca, [dba.tb].cb, [dba.tb].cc, [dba.tb].cd from [dba.tb] [dba.tb] where [dba.tb].cc= ?:? ) + + SORT (distinct) + TABLE SCAN (c) + + rewritten query: (select distinct c.ca from [dba.tc] c) + + SORT (order by) + HASH JOIN (inner join) + HASH JOIN (inner join) + TABLE SCAN (a) + TABLE SCAN (b) + TABLE SCAN (av?) + + rewritten query: select /*+ USE_HASH */ a.cd, b.cd, (select /*+ NO_SUBQUERY_CACHE */ d.cd from [dba.td] d where d.cd=b.cd and d.cd=b.cd) from (select /*+ NO_MERGE */ [dba.ta].ca, [dba.ta].cb, [dba.ta].cc, [dba.ta].cd from [dba.ta] [dba.ta] where [dba.ta].cc= ?:? ) a (ca, cb, cc, cd), (select /*+ NO_MERGE */ [dba.tb].ca, [dba.tb].cb, [dba.tb].cc, [dba.tb].cd from [dba.tb] [dba.tb] where [dba.tb].cc= ?:? ) b (ca, cb, cc, cd), (select distinct c.ca from [dba.tc] c) av? (av_?) where a.cd=b.cd and a.ca=av?.av_? order by ? + + +Trace Statistics: + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + ORDERBY (time: ?, sort: true, page: ?, ioread: ?) + SUBQUERY (uncorrelated) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.ta), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.tb), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.tc), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + ORDERBY (time: ?, sort: true, page: ?, ioread: ?) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: memory) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: memory) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + SUBQUERY (correlated) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (index: dba.td.i_c), (btree time: ?, fetch: ?, ioread: ?, readkeys: ?, filteredkeys: ?, rows: ?, covered: true) + + +=================================================== +0 +=================================================== + +#### 7. ctes (common table expressions) + +=================================================== +c_cd d_cd +4 4 +1004 1004 + +Query plan: +hash-join (inner join) + edge: term[?] + outer: iscan + class: a node[?] + index: i_a term[?] + cost: ? card ? + inner: iscan + class: b node[?] + index: i_a term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ USE_HASH */ a.ca, a.cb, a.cc, a.cd from ta a, tb b where a.cd=b.cd and b.ca= ?:? and a.ca= ?:? +Query plan: +temp(order by) + subplan: hash-join (inner join) + edge: term[?] + outer: sscan + simple CTE:c node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +with cte(ca, cb, cc, cd) as (select /*+ USE_HASH */ a.ca, a.cb, a.cc, a.cd from ta a, tb b where a.cd=b.cd and b.ca= ?:? and a.ca= ?:? )select /*+ USE_HASH */ c.cd, d.cd from cte c, td d where c.cd=d.cd and d.cc= ?:? and c.cc= ?:? order by ? +=================================================== +trace + +Query Plan: + HASH JOIN (inner join) + INDEX SCAN (a.i_a) (key range: a.ca= ?:? ) + INDEX SCAN (b.i_a) (key range: b.ca= ?:? ) + + rewritten query: select /*+ USE_HASH */ a.ca, a.cb, a.cc, a.cd from [dba.ta] a, [dba.tb] b where a.cd=b.cd and b.ca= ?:? and a.ca= ?:? + + SORT (order by) + HASH JOIN (inner join) + TABLE SCAN (c) + TABLE SCAN (d) + + rewritten query: with cte(ca, cb, cc, cd) as (select /*+ USE_HASH */ a.ca, a.cb, a.cc, a.cd from [dba.ta] a, [dba.tb] b where a.cd=b.cd and b.ca= ?:? and a.ca= ?:? )select /*+ USE_HASH */ c.cd, d.cd from [dba.cte] c, [dba.td] d where c.cd=d.cd and d.cc= ?:? and c.cc= ?:? order by ? + + +Trace Statistics: + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + ORDERBY (time: ?, sort: true, page: ?, ioread: ?) + SUBQUERY (uncorrelated) + CTE (non_recursive_part) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: memory) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (index: dba.tb.i_a), (btree time: ?, fetch: ?, ioread: ?, readkeys: ?, filteredkeys: ?, rows: ?) (lookup time: ?, rows: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (index: dba.ta.i_a), (btree time: ?, fetch: ?, ioread: ?, readkeys: ?, filteredkeys: ?, rows: ?) (lookup time: ?, rows: ?) + HASHJOIN (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + BUILD (time: ?, build_time: ?, fetch: ?, fetch_time: ?, ioread: ?, hash_method: memory) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (table: dba.td), (heap time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + PROBE (time: ?, probe_time: ?, fetch: ?, fetch_time: ?, ioread: ?, readkeys: ?, rows: ?, max_collisions: ?) + SELECT (time: ?, fetch: ?, fetch_time: ?, ioread: ?) + SCAN (temp time: ?, fetch: ?, ioread: ?, readrows: ?, rows: ?) + + +=================================================== +0 +=================================================== + +#### 8. json format output + +=================================================== +0 +=================================================== +a_cd b_cd +5 5 +1005 1005 + +Query plan: +temp(order by) + subplan: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + sort: ? asc + cost: ? card ? +Query stmt: +select /*+ USE_HASH */ a.cd, b.cd from ta a, tb b where a.cd=b.cd and b.cc= ?:? and a.cc= ?:? order by ? +=================================================== +trace +{ + "Query Plan": { + "SORT (order by)": { + "HASH JOIN (inner join)": [ + { + "TABLE SCAN": { + "table": "a" + } + }, + { + "TABLE SCAN": { + "table": "b" + } + } + ] + }, + "rewritten query": "select /*+ USE_HASH */ a.cd, b.cd from [dba.ta] a, [dba.tb] b where a.cd=b.cd and b.cc= ?:? and a.cc= ?:? order by ?" + }, + "Trace Statistics": { + "SELECT": { + "time": ?, + "fetch": ?, + "fetch_time": ?, + "ioread": ?, + "SCAN": { + "access": "temp", + "temp": { + "time": ?, + "fetch": ?, + "ioread": ?, + "readrows": ?, + "rows": ? + } + }, + "ORDERBY": { + "time": ?, + "sort": true, + "page": ?, + "ioread": ? + }, + "SUBQUERY (uncorrelated)": [ + { + "HASHJOIN": { + "time": ?, + "fetch": ?, + "fetch_time": ?, + "ioread": ?, + "build": { + "time": ?, + "build_time": ?, + "fetch": ?, + "fetch_time": ?, + "ioread": ?, + "hash_method": "memory", + "input": { + "SELECT": { + "time": ?, + "fetch": ?, + "fetch_time": ?, + "ioread": ?, + "SCAN": { + "access": "table (dba.tb)", + "heap": { + "time": ?, + "fetch": ?, + "ioread": ?, + "readrows": ?, + "rows": ? + } + } + } + } + }, + "probe": { + "time": ?, + "probe_time": ?, + "fetch": ?, + "fetch_time": ?, + "ioread": ?, + "readkeys": ?, + "rows": ?, + "max_collisions": ?, + "input": { + "SELECT": { + "time": ?, + "fetch": ?, + "fetch_time": ?, + "ioread": ?, + "SCAN": { + "access": "table (dba.ta)", + "heap": { + "time": ?, + "fetch": ?, + "ioread": ?, + "readrows": ?, + "rows": ? + } + } + } + } + } + } + } + ] + } + } +} + +=================================================== +0 +=================================================== +0 +=================================================== +0 diff --git a/sql/_35_fig_cake/cbrd_25382/answers/cbrd_25382_6.answer b/sql/_35_fig_cake/cbrd_25382/answers/cbrd_25382_6.answer new file mode 100755 index 0000000000..f3de477392 --- /dev/null +++ b/sql/_35_fig_cake/cbrd_25382/answers/cbrd_25382_6.answer @@ -0,0 +1,720 @@ +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +8 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== + +#### 1. hint: recompile ordered use_hash + +=================================================== +4 +=================================================== +12 +Query plan: +hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH */ d,class d,c,class c,b,class b, ?:? as [b.flag], ?:? as [c.flag], ?:? as [d.flag] from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_flag c_flag d_flag +1 1 1 1 1 +2 1 1 1 1 +3 1 1 1 1 +4 1 1 1 1 +5 null null null null +6 null null null null +7 null null null null +8 null null null null + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 2. hint: recompile ordered use_hash(a) + +=================================================== +1 +=================================================== +3 +Query plan: +nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH(a) */ d,class d,c,class c,b,class b, ?:? as [b.flag], ?:? as [c.flag], ?:? as [d.flag] from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_flag c_flag d_flag +1 1 1 1 1 +2 null null null null +3 null null null null +4 null null null null +5 null null null null +6 null null null null +7 null null null null +8 null null null null + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 3. hint: recompile ordered use_hash(b) + +=================================================== +1 +=================================================== +3 +Query plan: +nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH(b) */ d,class d,c,class c,b,class b, ?:? as [b.flag], ?:? as [c.flag], ?:? as [d.flag] from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_flag c_flag d_flag +1 null null null null +2 1 1 1 1 +3 null null null null +4 null null null null +5 null null null null +6 null null null null +7 null null null null +8 null null null null + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 4. hint: recompile ordered use_hash(c) + +=================================================== +1 +=================================================== +3 +Query plan: +nl-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH(c) */ d,class d,c,class c,b,class b, ?:? as [b.flag], ?:? as [c.flag], ?:? as [d.flag] from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_flag c_flag d_flag +1 null null null null +2 null null null null +3 1 1 1 1 +4 null null null null +5 null null null null +6 null null null null +7 null null null null +8 null null null null + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 5. hint: recompile ordered use_hash(d) + +=================================================== +1 +=================================================== +3 +Query plan: +hash-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED USE_HASH(d) */ d,class d,c,class c,b,class b, ?:? as [b.flag], ?:? as [c.flag], ?:? as [d.flag] from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_flag c_flag d_flag +1 null null null null +2 null null null null +3 null null null null +4 1 1 1 1 +5 null null null null +6 null null null null +7 null null null null +8 null null null null + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 6. hint: recompile ordered use_hash no_use_hash + +=================================================== +8 +=================================================== +24 +Query plan: +nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH USE_HASH */ d,class d,c,class c,b,class b, ?:? as [b.flag], ?:? as [c.flag], ?:? as [d.flag] from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_flag c_flag d_flag +1 1 1 1 1 +2 1 1 1 1 +3 1 1 1 1 +4 1 1 1 1 +5 1 1 1 1 +6 1 1 1 1 +7 1 1 1 1 +8 1 1 1 1 + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 7. hint: recompile ordered use_hash no_use_hash(a) + +=================================================== +5 +=================================================== +15 +Query plan: +hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(a) USE_HASH */ d,class d,c,class c,b,class b, ?:? as [b.flag], ?:? as [c.flag], ?:? as [d.flag] from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_flag c_flag d_flag +1 1 1 1 1 +2 1 1 1 1 +3 1 1 1 1 +4 1 1 1 1 +5 1 1 1 1 +6 null null null null +7 null null null null +8 null null null null + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 8. hint: recompile ordered use_hash no_use_hash(b) + +=================================================== +5 +=================================================== +15 +Query plan: +hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(b) USE_HASH */ d,class d,c,class c,b,class b, ?:? as [b.flag], ?:? as [c.flag], ?:? as [d.flag] from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_flag c_flag d_flag +1 1 1 1 1 +2 1 1 1 1 +3 1 1 1 1 +4 1 1 1 1 +5 null null null null +6 1 1 1 1 +7 null null null null +8 null null null null + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 9. hint: recompile ordered use_hash no_use_hash(c) + +=================================================== +5 +=================================================== +15 +Query plan: +hash-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(c) USE_HASH */ d,class d,c,class c,b,class b, ?:? as [b.flag], ?:? as [c.flag], ?:? as [d.flag] from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_flag c_flag d_flag +1 1 1 1 1 +2 1 1 1 1 +3 1 1 1 1 +4 1 1 1 1 +5 null null null null +6 null null null null +7 1 1 1 1 +8 null null null null + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 10. hint: recompile ordered use_hash no_use_hash(d) + +=================================================== +5 +=================================================== +15 +Query plan: +nl-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(d) USE_HASH */ d,class d,c,class c,b,class b, ?:? as [b.flag], ?:? as [c.flag], ?:? as [d.flag] from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_flag c_flag d_flag +1 1 1 1 1 +2 1 1 1 1 +3 1 1 1 1 +4 1 1 1 1 +5 null null null null +6 null null null null +7 null null null null +8 1 1 1 1 + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 11. hint: recompile ordered use_hash(a,b) no_use_hash(c,d) + +=================================================== +4 +=================================================== +12 +Query plan: +nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(c, d) USE_HASH(a, b) */ d,class d,c,class c,b,class b, ?:? as [b.flag], ?:? as [c.flag], ?:? as [d.flag] from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_flag c_flag d_flag +1 1 1 1 1 +2 1 1 1 1 +3 null null null null +4 null null null null +5 null null null null +6 null null null null +7 1 1 1 1 +8 1 1 1 1 + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 12. hint: recompile ordered use_hash(a,c) no_use_hash(b,d) + +=================================================== +4 +=================================================== +12 +Query plan: +nl-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(b, d) USE_HASH(a, c) */ d,class d,c,class c,b,class b, ?:? as [b.flag], ?:? as [c.flag], ?:? as [d.flag] from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_flag c_flag d_flag +1 1 1 1 1 +2 null null null null +3 1 1 1 1 +4 null null null null +5 null null null null +6 1 1 1 1 +7 null null null null +8 1 1 1 1 + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 13. hint: recompile ordered use_hash(a,b,c) no_use_hash(b,d) + +=================================================== +5 +=================================================== +15 +Query plan: +nl-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(b, d) USE_HASH(a, b, c) */ d,class d,c,class c,b,class b, ?:? as [b.flag], ?:? as [c.flag], ?:? as [d.flag] from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_flag c_flag d_flag +1 1 1 1 1 +2 1 1 1 1 +3 1 1 1 1 +4 null null null null +5 null null null null +6 1 1 1 1 +7 null null null null +8 1 1 1 1 + +=================================================== +0 +=================================================== +0 +=================================================== + +#### 14. hint: recompile ordered use_hash(b,c,d) no_use_hash(b,c,d) + +=================================================== +6 +=================================================== +18 +Query plan: +nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: a node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: d node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ ORDERED NO_USE_HASH(b, c, d) USE_HASH(b, c, d) */ d,class d,c,class c,b,class b, ?:? as [b.flag], ?:? as [c.flag], ?:? as [d.flag] from ta a, tb b, tc c, td d where a.ca=b.ca and b.ca=c.ca and c.ca=d.ca and a.flag= ?:? +=================================================== +a_ca a_flag b_flag c_flag d_flag +1 null null null null +2 1 1 1 1 +3 1 1 1 1 +4 1 1 1 1 +5 null null null null +6 1 1 1 1 +7 1 1 1 1 +8 1 1 1 1 + +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +0 diff --git a/sql/_35_fig_cake/cbrd_25382/answers/cbrd_25382_7.answer b/sql/_35_fig_cake/cbrd_25382/answers/cbrd_25382_7.answer new file mode 100755 index 0000000000..6f53161c21 --- /dev/null +++ b/sql/_35_fig_cake/cbrd_25382/answers/cbrd_25382_7.answer @@ -0,0 +1,324 @@ +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +4 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== +0 +=================================================== + +#### 1. hint: recompile use_hash + +=================================================== +a_ca b_ca c_ca +1 1 1 +2 2 2 +3 3 3 +4 4 4 + +Query plan: +hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: ab node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ USE_HASH */ ab.ca, b.ca, c.ca from ta ab, tb b, tc c where (b.ca=c.ca) and (ab.ca=b.ca) and b.flag= ?:? and ab.flag= ?:? and c.flag= ?:? +=================================================== +0 +=================================================== + +#### 2. hint: recompile + use_hash + +=================================================== +a_ca b_ca c_ca +1 1 1 +2 2 2 +3 3 3 +4 4 4 + +Query plan: +hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: ab node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ USE_HASH */ ab.ca, b.ca, c.ca from ta ab, tb b, tc c where (b.ca=c.ca) and (ab.ca=b.ca) and b.flag= ?:? and ab.flag= ?:? and c.flag= ?:? +=================================================== +0 +=================================================== + +#### 3. hint: recompile use_hash + use_hash + +=================================================== +a_ca b_ca c_ca +1 1 1 +2 2 2 +3 3 3 +4 4 4 + +Query plan: +hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: ab node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ USE_HASH */ ab.ca, b.ca, c.ca from ta ab, tb b, tc c where (b.ca=c.ca) and (ab.ca=b.ca) and b.flag= ?:? and ab.flag= ?:? and c.flag= ?:? +=================================================== +0 +=================================================== + +#### 4. hint: recompile no_use_hash + use_hash + +=================================================== +a_ca b_ca c_ca +1 1 1 +2 2 2 +3 3 3 +4 4 4 + +Query plan: +nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: ab node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] AND term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] AND term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ NO_USE_HASH USE_HASH */ ab.ca, b.ca, c.ca from ta ab, tb b, tc c where (b.ca=c.ca) and (ab.ca=b.ca) and b.flag= ?:? and ab.flag= ?:? and c.flag= ?:? +=================================================== +0 +=================================================== + +#### 5. hint: recompile use_hash(ab,c) + use_hash(a,b) + +=================================================== +a_ca b_ca c_ca +1 1 1 +2 2 2 +3 3 3 +4 4 4 + +Query plan: +hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: ab node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ USE_HASH(ab, c, a, b) */ ab.ca, b.ca, c.ca from ta ab, tb b, tc c where (b.ca=c.ca) and (ab.ca=b.ca) and b.flag= ?:? and ab.flag= ?:? and c.flag= ?:? +=================================================== +0 +=================================================== + +#### 6. hint: recompile use_hash(ab) + no_use_hash(a) + +=================================================== +a_ca b_ca c_ca +1 1 1 +2 2 2 +3 3 3 +4 4 4 + +Query plan: +nl-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: ab node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] AND term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] AND term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ NO_USE_HASH(a) USE_HASH(ab) */ ab.ca, b.ca, c.ca from ta ab, tb b, tc c where (b.ca=c.ca) and (ab.ca=b.ca) and b.flag= ?:? and ab.flag= ?:? and c.flag= ?:? +=================================================== +0 +=================================================== + +#### 7. hint: recompile no_use_hash(ab) + use_hash(a) + +=================================================== +a_ca b_ca c_ca +1 1 1 +2 2 2 +3 3 3 +4 4 4 + +Query plan: +nl-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: ab node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] AND term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ NO_USE_HASH(ab) USE_HASH(a) */ ab.ca, b.ca, c.ca from ta ab, tb b, tc c where (b.ca=c.ca) and (ab.ca=b.ca) and b.flag= ?:? and ab.flag= ?:? and c.flag= ?:? +=================================================== +0 +=================================================== + +#### 8. hint: recompile no_use_hash(a,b,c) + use_hash(a,b,c) + +=================================================== +a_ca b_ca c_ca +1 1 1 +2 2 2 +3 3 3 +4 4 4 + +Query plan: +hash-join (inner join) + edge: term[?] + outer: hash-join (inner join) + edge: term[?] + outer: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: ab node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ NO_USE_HASH(c) USE_HASH(a, b) */ ab.ca, b.ca, c.ca from ta ab, tb b, tc c where (b.ca=c.ca) and (ab.ca=b.ca) and b.flag= ?:? and ab.flag= ?:? and c.flag= ?:? +=================================================== +0 +=================================================== + +#### 9. hint: recompile use_hash(a,b,c) + no_use_hash(a,b,c) + +=================================================== +a_ca b_ca c_ca +1 1 1 +2 2 2 +3 3 3 +4 4 4 + +Query plan: +hash-join (inner join) + edge: term[?] + outer: nl-join (inner join) + edge: term[?] + outer: sscan + class: ab node[?] + sargs: term[?] + cost: ? card ? + inner: sscan + class: b node[?] + sargs: term[?] AND term[?] + cost: ? card ? + cost: ? card ? + inner: sscan + class: c node[?] + sargs: term[?] + cost: ? card ? + cost: ? card ? +Query stmt: +select /*+ NO_USE_HASH(a, b) USE_HASH(c) */ ab.ca, b.ca, c.ca from ta ab, tb b, tc c where (b.ca=c.ca) and (ab.ca=b.ca) and b.flag= ?:? and ab.flag= ?:? and c.flag= ?:? +=================================================== +0 +=================================================== +0 diff --git a/sql/_35_fig_cake/cbrd_25382/cases/cbrd_25382_1.sql b/sql/_35_fig_cake/cbrd_25382/cases/cbrd_25382_1.sql new file mode 100644 index 0000000000..230ddc5679 --- /dev/null +++ b/sql/_35_fig_cake/cbrd_25382/cases/cbrd_25382_1.sql @@ -0,0 +1,159 @@ +/** + * This test case verifies CBRD-25382: Support HASH JOIN with hint required + * cbrd_25382_1: cost.sql + * 1. build input: small tuple count + * 2. build input: small tuple count + ordered + * 3. build input: int vs bigint -> int or bigint (page: int == bigint) + * 4. build input: int vs numeric -> int (page: int < numeric) + * 5. cost: in_memory, hybrid < file, build_method: in_memory + * 6. cost: in_memory, hybrid < file, build_method: hybrid + * 7. cost: in_memory, hybrid < file, build_method: file + */ + +set @i = 0; + +drop table if exists ta, tb, tc, td, t_bigint, t_numeric; +create table ta (ca int, cb int, cc int, cd int, index i_a (ca, cb, cc), index i_b (cb, cc), index i_c (cd)); +create table tb (ca int, cb int, cc int, cd int, index i_a (ca, cb, cc), index i_b (cb, cc), index i_c (cd)); +create table tc (ca int, cb int, cc int, cd int, index i_a (ca, cb, cc), index i_b (cb, cc), index i_c (cd)); +create table td (ca int, cb int, cc int, cd int, index i_a (ca, cb, cc), index i_b (cb, cc), index i_c (cd)); +create table t_bigint (ca bigint, cb bigint, cc bigint, cd bigint, index i_a (ca, cb, cc), index i_b (cb, cc), index i_c (cd)); +create table t_numeric (ca numeric (10, 0), cb numeric (10, 0), cc numeric (10, 0), cd numeric (10, 0), index i_a (ca, cb, cc), index i_b (cb, cc), index i_c (cd)); + +insert into ta + with recursive cte (n) as ( + select 1 + union all + select n + 1 from cte where n < 2000 + ) + select mod (n, 10), mod (n, 100), mod (n, 1000), n from cte; +insert into tb select * from ta; +insert into tc select * from ta; +insert into td select * from ta; +insert into t_bigint select * from ta; +insert into t_numeric select * from ta; + +update statistics on ta, tb, tc, td, t_bigint, t_numeric with fullscan; + +set trace on; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. build input: small tuple count'); + +--@queryplan +select /*+ recompile use_hash */ + count (*) +from ta a, tb b, tc c, td d +where a.cd = b.cd and b.cd = c.cd and c.cd = d.cd + and a.cb in (1, 2) /* expected results: 40 */ + and b.cb in (1, 2, 3) /* expected results: 60 */ + and c.cb in (1, 2, 3, 4) /* expected results: 80 */ + and d.cb in (1) /* expected results: 20 */ + ; + +show trace; +--select trace_stats (); + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. build input: small tuple count + ordered'); + +--@queryplan +select /*+ recompile ordered use_hash */ + count (*) +from ta a, tb b, tc c, td d +where a.cd = b.cd and b.cd = c.cd and c.cd = d.cd + and a.cb in (1, 2, 3) /* expected results: 60 */ + and b.cb in (1, 2, 3, 4) /* expected results: 80 */ + and c.cb in (1) /* expected results: 40 */ + and d.cb in (1, 2) /* expected results: 20 */ + ; + +show trace; +--select trace_stats (); + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. build input: int vs bigint -> int or bigint (page: int == bigint)'); + +--@queryplan +select /*+ recompile use_hash */ + count (*) +from ta a, t_bigint b +where a.ca = b.ca and a.cb = b.cb and a.cc = b.cc and a.cd = b.cd; + +show trace; +--select trace_stats (); + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. build input: int vs numeric -> int (page: int < numeric)'); + +--@queryplan +select /*+ recompile use_hash */ + count (*) +from ta a, t_numeric b +where a.ca = b.ca and a.cb = b.cb and a.cc = b.cc and a.cd = b.cd; + +show trace; +--select trace_stats (); + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. cost: in_memory, hybrid < file, build_method: in_memory'); + +set system parameters 'max_hash_list_scan_size=512k'; + +--@queryplan +select /*+ recompile use_hash(a,b) use_nl(c) */ + count (*) +from ta a, tb b, tc c +where a.ca = b.ca and a.cb = b.cb and a.cc = b.cc and a.cd = b.cd + and a.ca = c.ca and a.cb = c.cb and a.cc = c.cc and a.cd = c.cd; + +show trace; +--select trace_stats (); + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. cost: in_memory, hybrid < file, build_method: hybrid'); + +set system parameters 'max_hash_list_scan_size=128k'; + +--@queryplan +select /*+ recompile use_hash(a,b) use_nl(c) */ + count (*) +from ta a, tb b, tc c +where a.ca = b.ca and a.cb = b.cb and a.cc = b.cc and a.cd = b.cd + and a.ca = c.ca and a.cb = c.cb and a.cc = c.cc and a.cd = c.cd; + +show trace; +--select trace_stats (); + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. cost: in_memory, hybrid < file, build_method: file'); + +set system parameters 'max_hash_list_scan_size=64k'; + +--@queryplan +select /*+ recompile ordered use_hash(a,b) use_nl(c) */ + count (*) +from ta a, tb b, tc c +where a.ca = b.ca and a.cb = b.cb and a.cc = b.cc and a.cd = b.cd + and a.ca = c.ca and a.cb = c.cb and a.cc = c.cc and a.cd = c.cd; + +show trace; +--select trace_stats (); + +--@queryplan +select /*+ recompile use_hash(a,b) use_nl(c) */ + count (*) +from ta a, tb b, tc c +where a.ca = b.ca and a.cb = b.cb and a.cc = b.cc and a.cd = b.cd + and a.ca = c.ca and a.cb = c.cb and a.cc = c.cc and a.cd = c.cd; + +show trace; +--select trace_stats (); + +set system parameters 'max_hash_list_scan_size=default'; + +set trace off; + +drop table ta, tb, tc, td, t_bigint, t_numeric; +drop variable @i; + diff --git a/sql/_35_fig_cake/cbrd_25382/cases/cbrd_25382_2.sql b/sql/_35_fig_cake/cbrd_25382/cases/cbrd_25382_2.sql new file mode 100644 index 0000000000..ad7a116b83 --- /dev/null +++ b/sql/_35_fig_cake/cbrd_25382/cases/cbrd_25382_2.sql @@ -0,0 +1,350 @@ +/** + * This test case verifies CBRD-25382: Support HASH JOIN with hint required + * cbrd_25382_2: delete_hint.sql + * 1. hint: recompile ordered use_hash + * 2. hint: recompile ordered use_hash(a) + * 3. hint: recompile ordered use_hash(b) + * 4. hint: recompile ordered use_hash(c) + * 5. hint: recompile ordered use_hash(d) + * 6. hint: recompile ordered use_hash no_use_hash + * 7. hint: recompile ordered use_hash no_use_hash(a) + * 8. hint: recompile ordered use_hash no_use_hash(b) + * 9. hint: recompile ordered use_hash no_use_hash(c) + * 10. hint: recompile ordered use_hash no_use_hash(d) + * 11. hint: recompile ordered use_hash(a,b) no_use_hash(c,d) + * 12. hint: recompile ordered use_hash(a,c) no_use_hash(b,d) + * 13. hint: recompile ordered use_hash(a,b,c) no_use_hash(b,d) + * 14. hint: recompile ordered use_hash(b,c,d) no_use_hash(b,c,d) + * 15. hint: recompile use_hash + * 16. hint: recompile use_hash(a,b,c) -> split(d) + * 17. hint: recompile no_use_hash + * 18. hint: recompile no_use_hash(a,b) -> split(c,d) + * 19. hint: recompile use_hash(a,c) no_use_hash(b) -> split(d) + * 20. hint: recompile use_hash(a,b) + * 21. hint: recompile use_hash(a,b,c) + */ + +set @i = 0; + +drop table if exists ta, tb, tc, td; +create table ta (ca int, flag int); +insert into ta (ca) values (1), (2), (3), (4), (5), (6), (7), (8); +create table tb as select a.ca from ta a; +create table tc as select a.ca from ta a; +create table td as select a.ca from ta a; + +-- unnecessary +update statistics on ta, tb, tc, td with fullscan; + +prepare check_result from ' +select + a.ca as a_ca, a.flag as a_flag, b.ca as b_ca, c.ca as c_ca, d.ca as d_ca +from + ta a + left outer join tb b on b.ca = a.ca + left outer join tc c on c.ca = a.ca + left outer join td d on d.ca = a.ca +'; + +autocommit off; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash'); + +update ta a set a.flag = 1 where a.ca in (1, 2, 3, 4); + +--@queryplan +delete /*+ recompile ordered use_hash */ + b, c, d +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(a)'); + +update ta a set a.flag = 1 where a.ca in (1); + +--@queryplan +delete /*+ recompile ordered use_hash(a) */ + b, c, d +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(b)'); + +update ta a set a.flag = 1 where a.ca in (2); + +--@queryplan +delete /*+ recompile ordered use_hash(b) */ + b, c, d +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(c)'); + +update ta a set a.flag = 1 where a.ca in (3); + +--@queryplan +delete /*+ recompile ordered use_hash(c) */ + b, c, d +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(d)'); + +update ta a set a.flag = 1 where a.ca in (4); + +--@queryplan +delete /*+ recompile ordered use_hash(d) */ + b, c, d +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash no_use_hash'); + +update ta a set a.flag = 1 where a.ca in (1, 2, 3, 4, 5, 6, 7, 8); + +--@queryplan +delete /*+ recompile ordered use_hash no_use_hash */ + b, c, d +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash no_use_hash(a)'); + +update ta a set a.flag = 1 where a.ca in (1, 2, 3, 4, 5); + +--@queryplan +delete /*+ recompile ordered use_hash no_use_hash(a) */ + b, c, d +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash no_use_hash(b)'); + +update ta a set a.flag = 1 where a.ca in (1, 2, 3, 4, 6); + +--@queryplan +delete /*+ recompile ordered use_hash no_use_hash(b) */ + b, c, d +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash no_use_hash(c)'); + +update ta a set a.flag = 1 where a.ca in (1, 2, 3, 4, 7); + +--@queryplan +delete /*+ recompile ordered use_hash no_use_hash(c) */ + b, c, d +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash no_use_hash(d)'); + +update ta a set a.flag = 1 where a.ca in (1, 2, 3, 4, 8); + +--@queryplan +delete /*+ recompile ordered use_hash no_use_hash(d) */ + b, c, d +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(a,b) no_use_hash(c,d)'); + +update ta a set a.flag = 1 where a.ca in (1, 2, 7, 8); + +--@queryplan +delete /*+ recompile ordered use_hash(a,b) no_use_hash(c,d) */ + b, c, d +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(a,c) no_use_hash(b,d)'); + +update ta a set a.flag = 1 where a.ca in (1, 3, 6, 8); + +--@queryplan +delete /*+ recompile ordered use_hash(a,c) no_use_hash(b,d) */ + b, c, d +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(a,b,c) no_use_hash(b,d)'); + +update ta a set a.flag = 1 where a.ca in (1, 2, 3, 6, 8); + +--@queryplan +delete /*+ recompile ordered use_hash(a,b,c) no_use_hash(b,d) */ + b, c, d +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(b,c,d) no_use_hash(b,c,d)'); + +update ta a set a.flag = 1 where a.ca in (2, 3, 4, 6, 7, 8); + +--@queryplan +delete /*+ recompile ordered use_hash(b,c,d) no_use_hash(b,c,d) */ + b, c, d +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile use_hash'); + +update ta a set a.flag = 1 where a.ca in (1, 2, 3, 4); + +--@queryplan +delete /*+ recompile use_hash */ + b, c, d +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca /* and c.ca = d.ca */ and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile use_hash(a,b,c) -> split(d)'); + +update ta a set a.flag = 1 where a.ca in (1, 2, 3); + +--@queryplan +delete /*+ recompile use_hash(a,b,c) */ + b, c, d +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca /* and c.ca = d.ca */ and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile no_use_hash'); + +update ta a set a.flag = 1 where a.ca in (5, 6, 7, 8); + +--@queryplan +delete /*+ recompile no_use_hash */ + b, c, d +from ta a, tb b, tc c, td d +where a.ca = b.ca /* and b.ca = c.ca and c.ca = d.ca */ and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile no_use_hash(a,b) -> split(c,d)'); + +update ta a set a.flag = 1 where a.ca in (5, 6); + +--@queryplan +delete /*+ recompile no_use_hash(a,b) */ + b, c, d +from ta a, tb b, tc c, td d +where a.ca = b.ca /* and b.ca = c.ca and c.ca = d.ca */ and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile use_hash(a,c) no_use_hash(b) -> split(d)'); + +update ta a set a.flag = 1 where a.ca in (1, 3, 6); + +--@queryplan +delete /*+ recompile use_hash(a,c) no_use_hash(b) */ + b, c, d +from ta a, tb b, tc c, td d +where a.ca = b.ca /* and b.ca = c.ca and c.ca = d.ca */ and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile use_hash(a,b)'); + +update ta a set a.flag = 1 where a.ca in (1, 2); + +--@queryplan +delete /*+ recompile use_hash(a,b) */ + b, c, d +from ta a, tb b, tc c, td d +where a.ca = b.ca /* and b.ca = c.ca */ and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile use_hash(a,b,c)'); + +update ta a set a.flag = 1 where a.ca in (1, 2, 3); + +--@queryplan +delete /*+ recompile use_hash(a,b,c) */ + b, c, d +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca /* and c.ca = d.ca */ and a.flag = 1 and d.ca = 8; + +execute check_result; +rollback; + +autocommit on; + +deallocate prepare check_result; +drop table if exists ta, tb, tc, td; +drop variable @i; + diff --git a/sql/_35_fig_cake/cbrd_25382/cases/cbrd_25382_3.sql b/sql/_35_fig_cake/cbrd_25382/cases/cbrd_25382_3.sql new file mode 100644 index 0000000000..258bd30623 --- /dev/null +++ b/sql/_35_fig_cake/cbrd_25382/cases/cbrd_25382_3.sql @@ -0,0 +1,204 @@ +/** + * This test case verifies CBRD-25382: Support HASH JOIN with hint required + * cbrd_25382_3: outer_join.sql + * 1. left outer join (ansi) + * 2. left outer join (non-ansi) + * 3. left outer join + during join terms + * 4. left outer join (ansi) + after join terms + * 5. left outer join (non-ansi) + after join terms + * 6. right outer join (ansi) + * 7. right outer join (non-ansi) + * 8. right outer join + during join terms + * 9. right outer join (ansi) + after join terms + * 10. right outer join (non-ansi) + after join terms + */ + +set @i = 0; + +drop table if exists ta, tb, tc, td; +create table ta (ca int, flag int); +insert into ta values (1, 0), (2, 0), (3, 0), (4, 0); +insert into ta values (1, 1), (2, 1), (3, 1), (4, 1); +create table tb as select a.ca, a.flag from ta a where a.ca != 2; +create table tc as select a.ca, a.flag from ta a where a.ca != 3; +create table td as select a.ca, a.flag from ta a where a.ca != 4; + +--unnecessary +update statistics on ta, tb, tc, td with fullscan; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. left outer join (ansi)', ' ####'); + +--@queryplan +select /*+ recompile ordered use_hash */ + a.ca as a_ca, b.ca as b_ca, c.ca as c_ca, d.ca as d_ca +from + ta a + left outer join tb b on b.ca = a.ca and b.flag = 1 /* sarg term */ + left outer join tc c on c.ca = b.ca and c.flag = 1 /* sarg term */ + left outer join td d on d.ca = c.ca and d.flag = 1 /* sarg term */ +where + a.flag = 1 /* sarg term */ +order by + a.ca; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. left outer join (non-ansi)'); + +--@queryplan +select /*+ recompile ordered use_hash */ + a.ca as a_ca, b.ca as b_ca, c.ca as c_ca, d.ca as d_ca +from + ta a, tb b, tc c, td d +where + a.flag = 1 /* sarg term */ + and a.ca = b.ca(+) and b.flag(+) = 1 /* sarg term */ + and b.ca = c.ca(+) and c.flag(+) = 1 /* sarg term */ + and c.ca = d.ca(+) and d.flag(+) = 1 /* sarg term */ +order by + a.ca; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. left outer join + during join terms'); + +--@queryplan +select /*+ recompile ordered use_hash */ + a.ca as a_ca, b.ca as b_ca, c.ca as c_ca, d.ca as d_ca +from + ta a + left outer join tb b on b.ca = a.ca and b.flag = 1 /* sarg term */ and a.flag = 1 /* during join term */ + left outer join tc c on c.ca = b.ca and c.flag = 1 /* sarg term */ and b.flag = 1 /* during join term */ + left outer join td d on d.ca = c.ca and d.flag = 1 /* sarg term */ and c.flag = 1 /* during join term */ +where + a.flag = 1 /* sarg term */ +order by + a.flag, a.ca; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. left outer join (ansi) + after join terms'); + +--@queryplan +select /*+ recompile ordered use_hash */ + a.ca as a_ca, b.ca as b_ca, c.ca as c_ca, d.ca as d_ca +from + ta a + left outer join tb b on b.ca = a.ca + left outer join tc c on c.ca = b.ca + left outer join td d on d.ca = c.ca +where + a.flag = 1 /* sarg term */ + and nvl (b.flag, 0) = 0 /* after join term */ + and nvl (c.flag, 0) = 0 /* after join term */ + and nvl (d.flag, 0) = 0 /* after join term */ +order by + a.ca; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. left outer join (non-ansi) + after join terms'); + +--@queryplan +select /*+ recompile ordered use_hash */ + a.ca as a_ca, b.ca as b_ca, c.ca as c_ca, d.ca as d_ca +from + ta a, tb b, tc c, td d +where + a.flag = 1 /* sarg term */ + and a.ca = b.ca(+) and nvl (b.flag, 0) = 0 /* after join term */ + and b.ca = c.ca(+) and nvl (c.flag, 0) = 0 /* after join term */ + and c.ca = d.ca(+) and nvl (d.flag, 0) = 0 /* after join term */ +order by + a.ca; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. right outer join (ansi)'); + +--@queryplan +select /*+ recompile ordered use_hash */ + d.ca as d_ca, d.flag as d_flag, + c.ca as c_ca, c.flag as c_flag, + b.ca as b_ca, b.flag as b_flag, + a.ca as a_ca +from + td d + right outer join tc c on c.ca = d.ca + right outer join tb b on b.ca = c.ca + right outer join ta a on a.ca = b.ca +where + a.flag = 1 /* sarg term */ +order by + a.ca, b.flag, b.ca, c.flag, c.ca, d.flag, d.ca; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. right outer join (non-ansi)'); + +--@queryplan +select /*+ recompile ordered use_hash */ + d.ca as d_ca, d.flag as d_flag, + c.ca as c_ca, c.flag as c_flag, + b.ca as b_ca, b.flag as b_flag, + a.ca as a_ca +from + td d, tc c, tb b, ta a +where + a.flag = 1 /* sarg term */ + and d.ca(+) = c.ca + and c.ca(+) = b.ca + and b.ca(+) = a.ca +order by + a.ca, b.flag, b.ca, c.flag, c.ca, d.flag, d.ca; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. right outer join + during join terms'); + +--@queryplan +select /*+ recompile ordered use_hash */ + d.ca as d_ca, d.flag as d_flag, + c.ca as c_ca, c.flag as c_flag, + b.ca as b_ca, b.flag as b_flag, + a.ca as a_ca, a.flag as a_flag +from + td d + right outer join tc c on c.ca = d.ca and c.flag = 1 /* during join term */ + right outer join tb b on b.ca = c.ca and b.flag = 1 /* during join term */ + right outer join ta a on a.ca = b.ca and a.flag = 1 /* during join term */ +order by + a.flag, a.ca, b.flag, b.ca, c.flag, c.ca, d.flag, d.ca; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. right outer join (ansi) + after join terms'); + +--@queryplan +select /*+ recompile ordered use_hash */ + d.ca as d_ca, c.ca as c_ca, b.ca as b_ca, a.ca as a_ca +from + td d + right outer join tc c on c.ca = d.ca + right outer join tb b on b.ca = c.ca + right outer join ta a on a.ca = b.ca +where + a.flag = 1 /* sarg term */ + and nvl (d.flag, 0) = 0 /* after join term */ + and nvl (c.flag, 0) = 0 /* after join term */ + and nvl (b.flag, 0) = 0 /* after join term */ +order by + a.ca, b.ca, c.ca, d.ca; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. right outer join (non-ansi) + after join terms'); + +--@queryplan +select /*+ recompile ordered use_hash */ + d.ca as d_ca, c.ca as c_ca, b.ca as b_ca, a.ca as a_ca +from + td d, tc c, tb b, ta a +where + a.flag = 1 /* sarg term */ + and d.ca(+) = c.ca and nvl (d.flag, 0) = 0 /* after join term */ + and c.ca(+) = b.ca and nvl (c.flag, 0) = 0 /* after join term */ + and b.ca(+) = a.ca and nvl (b.flag, 0) = 0 /* after join term */ +order by + a.ca, b.ca, c.ca, d.ca; + +drop table ta, tb, tc, td; +drop variable @i; + diff --git a/sql/_35_fig_cake/cbrd_25382/cases/cbrd_25382_4.sql b/sql/_35_fig_cake/cbrd_25382/cases/cbrd_25382_4.sql new file mode 100644 index 0000000000..eb732555a6 --- /dev/null +++ b/sql/_35_fig_cake/cbrd_25382/cases/cbrd_25382_4.sql @@ -0,0 +1,174 @@ +/** + * This test case verifies CBRD-25382: Support HASH JOIN with hint required + * cbrd_25382_4: select_hint.sql + * 1. hint: recompile ordered use_hash + * 2. hint: recompile ordered use_hash(a) + * 3. hint: recompile ordered use_hash(b) + * 4. hint: recompile ordered use_hash(c) + * 5. hint: recompile ordered use_hash(d) + * 6. hint: recompile ordered use_hash no_use_hash + * 7. hint: recompile ordered use_hash no_use_hash(a) + * 8. hint: recompile ordered use_hash no_use_hash(b) + * 9. hint: recompile ordered use_hash no_use_hash(c) + * 10. hint: recompile ordered use_hash no_use_hash(d) + * 11. hint: recompile ordered use_hash(a,b) no_use_hash(c,d) + * 12. hint: recompile ordered use_hash(a,c) no_use_hash(b,d) + * 13. hint: recompile ordered use_hash(a,b,c) no_use_hash(b,d) + * 14. hint: recompile ordered use_hash(b,c,d) no_use_hash(b,c,d) + */ + +set @i = 0; + +drop table if exists ta, tb, tc, td; +create table ta (ca int); +insert into ta (ca) values (1), (2), (3), (4); +create table tb as select a.ca from ta a; +create table tc as select a.ca from ta a; +create table td as select a.ca from ta a; + +-- unnecessary +update statistics on ta, tb, tc, td with fullscan; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash'); + +--@queryplan +select /*+ recompile ordered use_hash */ + a.ca as a_ca, b.ca as b_ca, c.ca as c_ca, d.ca as d_ca +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca +order by a.ca; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(a)'); + +--@queryplan +select /*+ recompile ordered use_hash(a) */ + a.ca as a_ca, b.ca as b_ca, c.ca as c_ca, d.ca as d_ca +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca +order by a.ca; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(b)'); + +--@queryplan +select /*+ recompile ordered use_hash(b) */ + a.ca as a_ca, b.ca as b_ca, c.ca as c_ca, d.ca as d_ca +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca +order by a.ca; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(c)'); + +--@queryplan +select /*+ recompile ordered use_hash(c) */ + a.ca as a_ca, b.ca as b_ca, c.ca as c_ca, d.ca as d_ca +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca +order by a.ca; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(d)'); + +--@queryplan +select /*+ recompile ordered use_hash(d) */ + a.ca as a_ca, b.ca as b_ca, c.ca as c_ca, d.ca as d_ca +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca +order by a.ca; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash no_use_hash'); + +--@queryplan +select /*+ recompile ordered use_hash no_use_hash */ + a.ca as a_ca, b.ca as b_ca, c.ca as c_ca, d.ca as d_ca +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca +order by a.ca; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash no_use_hash(a)'); + +--@queryplan +select /*+ recompile ordered use_hash no_use_hash(a) */ + a.ca as a_ca, b.ca as b_ca, c.ca as c_ca, d.ca as d_ca +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca +order by a.ca; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash no_use_hash(b)'); + +--@queryplan +select /*+ recompile ordered use_hash no_use_hash(b) */ + a.ca as a_ca, b.ca as b_ca, c.ca as c_ca, d.ca as d_ca +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca +order by a.ca; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash no_use_hash(c)'); + +--@queryplan +select /*+ recompile ordered use_hash no_use_hash(c) */ + a.ca as a_ca, b.ca as b_ca, c.ca as c_ca, d.ca as d_ca +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca +order by a.ca; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash no_use_hash(d)'); + +--@queryplan +select /*+ recompile ordered use_hash no_use_hash(d) */ + a.ca as a_ca, b.ca as b_ca, c.ca as c_ca, d.ca as d_ca +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca +order by a.ca; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(a,b) no_use_hash(c,d)'); + +--@queryplan +select /*+ recompile ordered use_hash(a,b) no_use_hash(c,d) */ + a.ca as a_ca, b.ca as b_ca, c.ca as c_ca, d.ca as d_ca +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca +order by a.ca; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(a,c) no_use_hash(b,d)'); + +--@queryplan +select /*+ recompile ordered use_hash(a,c) no_use_hash(b,d) */ + a.ca as a_ca, b.ca as b_ca, c.ca as c_ca, d.ca as d_ca +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca +order by a.ca; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(a,b,c) no_use_hash(b,d)'); + +--@queryplan +select /*+ recompile ordered use_hash(a,b,c) no_use_hash(b,d) */ + a.ca as a_ca, b.ca as b_ca, c.ca as c_ca, d.ca as d_ca +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca +order by a.ca; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(b,c,d) no_use_hash(b,c,d)'); + +--@queryplan +select /*+ recompile ordered use_hash(b,c,d) no_use_hash(b,c,d) */ + a.ca as a_ca, b.ca as b_ca, c.ca as c_ca, d.ca as d_ca +from ta a, tb b, tc c, td d +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca +order by a.ca; + +drop table ta, tb, tc, td; +drop variable @i; + diff --git a/sql/_35_fig_cake/cbrd_25382/cases/cbrd_25382_5.sql b/sql/_35_fig_cake/cbrd_25382/cases/cbrd_25382_5.sql new file mode 100644 index 0000000000..63e2cffa05 --- /dev/null +++ b/sql/_35_fig_cake/cbrd_25382/cases/cbrd_25382_5.sql @@ -0,0 +1,165 @@ +/** + * This test case verifies CBRD-25382: Support HASH JOIN with hint required + * cbrd_25382_5: trace.sql + * 1. empty outer + * 2. empty inner + * 3. empty inner + left outer join + * 4. multiple tables + * 5. inline views + * 6. subqueries + * 7. ctes (common table expressions) + * 8. json format output + */ + +set @i = 0; + +drop table if exists ta, tb, tc, td; +create table ta (ca int, cb int, cc int, cd int, index i_a (ca, cb, cc), index i_b (cb, cc), index i_c (cd)); +create table tb (ca int, cb int, cc int, cd int, index i_a (ca, cb, cc), index i_b (cb, cc), index i_c (cd)); +create table tc (ca int, cb int, cc int, cd int, index i_a (ca, cb, cc), index i_b (cb, cc), index i_c (cd)); +create table td (ca int, cb int, cc int, cd int, index i_a (ca, cb, cc), index i_b (cb, cc), index i_c (cd)); + +insert into ta + with recursive cte (n) as ( + select 1 + union all + select n + 1 from cte where n < 2000 + ) + select mod (n, 10), mod (n, 100), mod (n, 1000), n from cte; +insert into tb select * from ta; +insert into tc select * from ta; +insert into td select * from ta; + +-- unnecessary +update statistics on ta, tb, tc, td with fullscan; + +set trace on; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. empty outer'); + +--@queryplan +select /*+ recompile ordered use_hash */ + a.cd as a_cd, b.cd as b_cd +from ta a, tb b +where a.cd = b.cd and a.ca = -1 +order by a.cd; + +show trace; +--select trace_stats (); + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. empty inner'); + +--@queryplan +select /*+ recompile ordered use_hash */ + a.cd as a_cd, b.cd as b_cd +from ta a, tb b +where a.cd = b.cd and b.ca = -1 +order by a.cd; + +show trace; +--select trace_stats (); + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. empty inner + left outer join'); + +--@queryplan +select /*+ recompile ordered use_hash */ + a.cd as a_cd, b.cd as b_cd +from ta a + left outer join tb b on b.cd = a.cd and b.ca = -1 +order by a.cd +limit 1999, 1; + +show trace; +--select trace_stats (); + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. multiple tables'); + +--@queryplan +select /*+ recompile use_hash */ + a.cd as a_cd, b.cd as b_cd, c.cd as c_cd, d.cd as d_cd +from ta a, tb b, tc c, td d +where a.cd = b.cd and b.cd = c.cd and c.cd = d.cd + and a.cc = 1 + and b.cc = 1 + and c.cc = 1 + and d.cc = 1 +order by a.cd; + +show trace; +--select trace_stats (); + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. inline views'); + +--@queryplan +select /*+ recompile use_hash */ + a.cd as a_cd, b.cd as b_cd +from + (select /*+ no_merge */ * from ta where cc = 2) a, + (select /*+ no_merge */ * from tb where cc = 2) b +where a.cd = b.cd +order by a.cd; + +show trace; +--select trace_stats (); + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. subqueries'); + +--@queryplan +select /*+ recompile use_hash */ + a.cd as a_cd, b.cd as b_cd, + (select /*+ no_subquery_cache */ d.cd from td d where d.cd = b.cd and d.cd = b.cd) as d_cd +from + (select /*+ no_merge */ * from ta where cc = 3) a, + (select /*+ no_merge */ * from tb where cc = 3) b +where a.cd = b.cd + and a.ca in (select distinct c.ca from tc c) +order by a.cd; + +show trace; +--select trace_stats (); + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. ctes (common table expressions)'); + +--@queryplan +with cte as ( + select /*+ use_hash */ + a.ca as ca, a.cb as cb, a.cc as cc, a.cd as cd + from ta a, tb b + where a.cd = b.cd and a.ca = 4 and b.ca = 4 + ) +select /*+ recompile use_hash */ + c.cd as c_cd, d.cd as d_cd +from cte c, td d +where c.cd = d.cd and c.cc = 4 and d.cc = 4 +order by c.cd; + +show trace; +--select trace_stats (); + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. json format output'); + +set trace on output json; + +--@queryplan +select /*+ recompile use_hash */ + a.cd as a_cd, b.cd as b_cd +from ta a, tb b +where a.cd = b.cd and a.cc = 5 and b.cc = 5 +order by a.cd; + +show trace; +--select trace_stats (); + +set trace off; + +drop table ta, tb, tc, td; +drop variable @i; + diff --git a/sql/_35_fig_cake/cbrd_25382/cases/cbrd_25382_6.sql b/sql/_35_fig_cake/cbrd_25382/cases/cbrd_25382_6.sql new file mode 100644 index 0000000000..662b7db22e --- /dev/null +++ b/sql/_35_fig_cake/cbrd_25382/cases/cbrd_25382_6.sql @@ -0,0 +1,245 @@ +/** + * This test case verifies CBRD-25382: Support HASH JOIN with hint required + * cbrd_25382_6: update_hint.sql + * 1. hint: recompile ordered use_hash + * 2. hint: recompile ordered use_hash(a) + * 3. hint: recompile ordered use_hash(b) + * 4. hint: recompile ordered use_hash(c) + * 5. hint: recompile ordered use_hash(d) + * 6. hint: recompile ordered use_hash no_use_hash + * 7. hint: recompile ordered use_hash no_use_hash(a) + * 8. hint: recompile ordered use_hash no_use_hash(b) + * 9. hint: recompile ordered use_hash no_use_hash(c) + * 10. hint: recompile ordered use_hash no_use_hash(d) + * 11. hint: recompile ordered use_hash(a,b) no_use_hash(c,d) + * 12. hint: recompile ordered use_hash(a,c) no_use_hash(b,d) + * 13. hint: recompile ordered use_hash(a,b,c) no_use_hash(b,d) + * 14. hint: recompile ordered use_hash(b,c,d) no_use_hash(b,c,d) + */ + +set @i = 0; + +drop table if exists ta, tb, tc, td; +create table ta (ca int, flag int); +insert into ta (ca) values (1), (2), (3), (4), (5), (6), (7), (8); +create table tb as select a.ca, a.flag from ta a; +create table tc as select a.ca, a.flag from ta a; +create table td as select a.ca, a.flag from ta a; + +-- unnecessary +update statistics on ta, tb, tc, td with fullscan; + +prepare check_result from ' +select + a.ca as a_ca, a.flag as a_flag, b.flag as b_flag, c.flag as c_flag, d.flag as d_flag +from + ta a + left outer join tb b on b.ca = a.ca + left outer join tc c on c.ca = a.ca + left outer join td d on d.ca = a.ca +'; + +autocommit off; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash'); + +update ta a set a.flag = 1 where a.ca in (1, 2, 3, 4); + +--@queryplan +update /*+ recompile ordered use_hash */ + ta a, tb b, tc c, td d +set b.flag = 1, c.flag = 1, d.flag = 1 +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(a)'); + +update ta a set a.flag = 1 where a.ca in (1); + +--@queryplan +update /*+ recompile ordered use_hash(a) */ + ta a, tb b, tc c, td d +set b.flag = 1, c.flag = 1, d.flag = 1 +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(b)'); + +update ta a set a.flag = 1 where a.ca in (2); + +--@queryplan +update /*+ recompile ordered use_hash(b) */ + ta a, tb b, tc c, td d +set b.flag = 1, c.flag = 1, d.flag = 1 +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(c)'); + +update ta a set a.flag = 1 where a.ca in (3); + +--@queryplan +update /*+ recompile ordered use_hash(c) */ + ta a, tb b, tc c, td d +set b.flag = 1, c.flag = 1, d.flag = 1 +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(d)'); + +update ta a set a.flag = 1 where a.ca in (4); + +--@queryplan +update /*+ recompile ordered use_hash(d) */ + ta a, tb b, tc c, td d +set b.flag = 1, c.flag = 1, d.flag = 1 +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash no_use_hash'); + +update ta a set a.flag = 1 where a.ca in (1, 2, 3, 4, 5, 6, 7, 8); + +--@queryplan +update /*+ recompile ordered use_hash no_use_hash */ + ta a, tb b, tc c, td d +set b.flag = 1, c.flag = 1, d.flag = 1 +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash no_use_hash(a)'); + +update ta a set a.flag = 1 where a.ca in (1, 2, 3, 4, 5); + +--@queryplan +update /*+ recompile ordered use_hash no_use_hash(a) */ + ta a, tb b, tc c, td d +set b.flag = 1, c.flag = 1, d.flag = 1 +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash no_use_hash(b)'); + +update ta a set a.flag = 1 where a.ca in (1, 2, 3, 4, 6); + +--@queryplan +update /*+ recompile ordered use_hash no_use_hash(b) */ + ta a, tb b, tc c, td d +set b.flag = 1, c.flag = 1, d.flag = 1 +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash no_use_hash(c)'); + +update ta a set a.flag = 1 where a.ca in (1, 2, 3, 4, 7); + +--@queryplan +update /*+ recompile ordered use_hash no_use_hash(c) */ + ta a, tb b, tc c, td d +set b.flag = 1, c.flag = 1, d.flag = 1 +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash no_use_hash(d)'); + +update ta a set a.flag = 1 where a.ca in (1, 2, 3, 4, 8); + +--@queryplan +update /*+ recompile ordered use_hash no_use_hash(d) */ + ta a, tb b, tc c, td d +set b.flag = 1, c.flag = 1, d.flag = 1 +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(a,b) no_use_hash(c,d)'); + +update ta a set a.flag = 1 where a.ca in (1, 2, 7, 8); + +--@queryplan +update /*+ recompile ordered use_hash(a,b) no_use_hash(c,d) */ + ta a, tb b, tc c, td d +set b.flag = 1, c.flag = 1, d.flag = 1 +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(a,c) no_use_hash(b,d)'); + +update ta a set a.flag = 1 where a.ca in (1, 3, 6, 8); + +--@queryplan +update /*+ recompile ordered use_hash(a,c) no_use_hash(b,d) */ + ta a, tb b, tc c, td d +set b.flag = 1, c.flag = 1, d.flag = 1 +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(a,b,c) no_use_hash(b,d)'); + +update ta a set a.flag = 1 where a.ca in (1, 2, 3, 6, 8); + +--@queryplan +update /*+ recompile ordered use_hash(a,b,c) no_use_hash(b,d) */ + ta a, tb b, tc c, td d +set b.flag = 1, c.flag = 1, d.flag = 1 +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile ordered use_hash(b,c,d) no_use_hash(b,c,d)'); + +update ta a set a.flag = 1 where a.ca in (2, 3, 4, 6, 7, 8); + +--@queryplan +update /*+ recompile ordered use_hash(b,c,d) no_use_hash(b,c,d) */ + ta a, tb b, tc c, td d +set b.flag = 1, c.flag = 1, d.flag = 1 +where a.ca = b.ca and b.ca = c.ca and c.ca = d.ca and a.flag = 1; + +execute check_result; +rollback; + +autocommit on; + +deallocate prepare check_result; +drop table ta, tb, tc, td; +drop variable @i; + diff --git a/sql/_35_fig_cake/cbrd_25382/cases/cbrd_25382_7.sql b/sql/_35_fig_cake/cbrd_25382/cases/cbrd_25382_7.sql new file mode 100644 index 0000000000..5b654199dc --- /dev/null +++ b/sql/_35_fig_cake/cbrd_25382/cases/cbrd_25382_7.sql @@ -0,0 +1,172 @@ +/** + * This test case verifies CBRD-25382: Support HASH JOIN with hint required + * cbrd_25382_7: view_merging.sql + * 1. hint: recompile use_hash + * 2. hint: recompile + use_hash + * 3. hint: recompile use_hash + use_hash + * 4. hint: recompile no_use_hash + use_hash + * 5. hint: recompile use_hash(ab,c) + use_hash(a,b) + * 6. hint: recompile use_hash(ab) + no_use_hash(a) + * 7. hint: recompile no_use_hash(ab) + use_hash(a) + * 8. hint: recompile no_use_hash(a,b,c) + use_hash(a,b,c) + * 9. hint: recompile use_hash(a,b,c) + no_use_hash(a,b,c) + */ + +set @i = 0; + +drop table if exists ta, tb, tc; +create table ta (ca int, flag int); +insert into ta values (1, 1), (2, 1), (3, 1), (4, 1); +create table tb as select a.ca, a.flag from ta a; +create table tc as select a.ca, a.flag from ta a; + +-- unnecessary +update statistics on ta, tb, tc with fullscan; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile use_hash'); + +--@queryplan +select /*+ recompile use_hash */ + ab.a_ca as a_ca, ab.b_ca as b_ca, c.ca as c_ca +from + ( + select + a.ca as a_ca, b.ca as b_ca + from ta a, tb b + where a.ca = b.ca and a.flag = 1 and b.flag = 1 + ) ab, + tc c +where ab.b_ca = c.ca and c.flag = 1; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile + use_hash'); + +--@queryplan +select /*+ recompile */ + ab.a_ca as a_ca, ab.b_ca as b_ca, c.ca as c_ca +from + ( + select /*+ use_hash */ + a.ca as a_ca, b.ca as b_ca + from ta a, tb b + where a.ca = b.ca and a.flag = 1 and b.flag = 1 + ) ab, + tc c +where ab.b_ca = c.ca and c.flag = 1; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile use_hash + use_hash'); + +--@queryplan +select /*+ recompile use_hash */ + ab.a_ca as a_ca, ab.b_ca as b_ca, c.ca as c_ca +from + ( + select /*+ use_hash */ + a.ca as a_ca, b.ca as b_ca + from ta a, tb b + where a.ca = b.ca and a.flag = 1 and b.flag = 1 + ) ab, + tc c +where ab.b_ca = c.ca and c.flag = 1; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile no_use_hash + use_hash'); + +--@queryplan +select /*+ recompile no_use_hash */ + ab.a_ca as a_ca, ab.b_ca as b_ca, c.ca as c_ca +from + ( + select /*+ use_hash */ + a.ca as a_ca, b.ca as b_ca + from ta a, tb b + where a.ca = b.ca and a.flag = 1 and b.flag = 1 + ) ab, + tc c +where ab.b_ca = c.ca and c.flag = 1; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile use_hash(ab,c) + use_hash(a,b)'); + +--@queryplan +select /*+ recompile use_hash(ab,c) */ + ab.a_ca as a_ca, ab.b_ca as b_ca, c.ca as c_ca +from + ( + select /*+ use_hash(a,b) */ + a.ca as a_ca, b.ca as b_ca + from ta a, tb b + where a.ca = b.ca and a.flag = 1 and b.flag = 1 + ) ab, + tc c +where ab.b_ca = c.ca and c.flag = 1; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile use_hash(ab) + no_use_hash(a)'); + +--@queryplan +select /*+ recompile use_hash(ab) */ + ab.a_ca as a_ca, ab.b_ca as b_ca, c.ca as c_ca +from + ( + select /*+ no_use_hash(a) */ + a.ca as a_ca, b.ca as b_ca + from ta a, tb b + where a.ca = b.ca and a.flag = 1 and b.flag = 1 + ) ab, + tc c +where ab.b_ca = c.ca and c.flag = 1; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile no_use_hash(ab) + use_hash(a)'); + +--@queryplan +select /*+ recompile no_use_hash(ab) */ + ab.a_ca as a_ca, ab.b_ca as b_ca, c.ca as c_ca +from + ( + select /*+ use_hash(a) */ + a.ca as a_ca, b.ca as b_ca + from ta a, tb b + where a.ca = b.ca and a.flag = 1 and b.flag = 1 + ) ab, + tc c +where ab.b_ca = c.ca and c.flag = 1; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile no_use_hash(a,b,c) + use_hash(a,b,c)'); + +--@queryplan +select /*+ recompile no_use_hash(a,b,c) */ + ab.a_ca as a_ca, ab.b_ca as b_ca, c.ca as c_ca +from + ( + select /*+ use_hash(a,b,c) */ + a.ca as a_ca, b.ca as b_ca + from ta a, tb b + where a.ca = b.ca and a.flag = 1 and b.flag = 1 + ) ab, + tc c +where ab.b_ca = c.ca and c.flag = 1; + +do @i := @i + 1; +evaluate concat ('####', lpad (@i, 3), '. hint: recompile use_hash(a,b,c) + no_use_hash(a,b,c)'); + +--@queryplan +select /*+ recompile use_hash(a,b,c) */ + ab.a_ca as a_ca, ab.b_ca as b_ca, c.ca as c_ca +from + ( + select /*+ no_use_hash(a,b,c) */ + a.ca as a_ca, b.ca as b_ca + from ta a, tb b + where a.ca = b.ca and a.flag = 1 and b.flag = 1 + ) ab, + tc c +where ab.b_ca = c.ca and c.flag = 1; + +drop table ta, tb, tc; +drop variable @i; +