Transformation之Subquery Un-nesting(子查詢的非巢狀)SU【六】

哎呀我的天吶發表於2015-02-27

                   把subquery merge到它的外面的query(啟發)

網上說exist要比in快之列的優化法則,但是至少oracle 10g後,這些事情oracle會去做,但是有時候不去做,所以要是能寫成exist,那麼就儘量寫成exist。

點選( 此處 )摺疊或開啟

  1. alter session set events '10053 trace name context forever,level 1';

  2. select * from dept where deptno in ( select deptno from emp where sal > 3000 ) ;

  3. alter session set events '10053 trace name context off';


點選( 此處 )摺疊或開啟

  1. Trace file /u01/app/oracle/diag/rdbms/testdb12/TestDB12/trace/TestDB12_ora_27778 . trc

  2. Oracle Database 11g Enterprise Edition Release 11 . 2 . . 3 . 0 - 64bit Production

  3. With the Partitioning , Oracle Label Security , OLAP , Data Mining ,

  4. Oracle Database Vault and Real Application Testing options

  5. ORACLE_HOME = /u01/app/oracle/product/11 . 2 . 0/dbhome_1

  6. System name :     Linux

  7. Node name :     test11g

  8. Release :     2 . 6 . 18 - 194 . el5

  9. Version :     #1 SMP Tue Mar 16 21 : 52 : 39 EDT 2010

  10. Machine :     x86_64

  11. Instance name : TestDB12

  12. Redo thread mounted by this instance : 1

  13. Oracle process number : 32

  14. Unix process pid : 27778 , image : oracle@test11g ( TNS V1 - V3 )



  15. * * * 2015 - 02 - 27 03 : 28 : 42 . 034

  16. * * * SESSION ID : ( 53 . 2993 ) 2015 - 02 - 27 03 : 28 : 42 . 034

  17. * * * CLIENT ID : ( ) 2015 - 02 - 27 03 : 28 : 42 . 034

  18. * * * SERVICE NAME : ( SYS$USERS ) 2015 - 02 - 27 03 : 28 : 42 . 034

  19. * * * MODULE NAME : ( SQL * Plus ) 2015 - 02 - 27 03 : 28 : 42 . 034

  20. * * * ACTION NAME : ( ) 2015 - 02 - 27 03 : 28 : 42 . 034

  21.  

  22. Registered qb : SEL$1 0x57631638 ( PARSER )

  23. - - - - - - - - - - - - - - - - - - - - -

  24. QUERY BLOCK SIGNATURE

  25. - - - - - - - - - - - - - - - - - - - - -

  26.   signature ( ) : qb_name = SEL$1 nbfros = 1 flg =

  27.     fro ( ) : flg = 4 objn = 75333 hint_alias = \ "DEPT\" @ \ "SEL$1\"


  28. Registered qb : SEL$2 0x5763c120 ( PARSER )

  29. - - - - - - - - - - - - - - - - - - - - -

  30. QUERY BLOCK SIGNATURE

  31. - - - - - - - - - - - - - - - - - - - - -

  32.   signature ( ) : qb_name = SEL$2 nbfros = 1 flg =

  33.     fro ( ) : flg = 4 objn = 75335 hint_alias = \ "EMP\" @ \ "SEL$2\"


  34. SPM : statement not found in SMB


  35. * * * * * * * * * * * * * * * * * * * * * * * * * *

  36. Automatic degree of parallelism ( ADOP )

  37. * * * * * * * * * * * * * * * * * * * * * * * * * *

  38. Automatic degree of parallelism is disabled : Parameter .


  39. PM : Considering predicate move - around in query block SEL$1 ( # )

  40. * * * * * * * * * * * * * * * * * * * * * * * * * *

  41. Predicate Move - Around ( PM )

  42. * * * * * * * * * * * * * * * * * * * * * * * * * *

  43. OPTIMIZER INFORMATION


  44. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  45. - - - - - Current SQL Statement for this session ( sql_id = dnkzmnvvdxgtm ) - - - - -

  46. select * from dept where deptno in ( select deptno from emp where sal > 3000 )

  47. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  48. Legend

  49. The following abbreviations are used by optimizer trace .

  50. CBQT - cost - based query transformation

  51. JPPD - join predicate push - down

  52. OJPPD - old - style ( non - cost - based ) JPPD

  53. FPD - filter push - down

  54. PM - predicate move - around

  55. CVM - complex view merging

  56. SPJ - select - project - join

  57. SJC - set join conversion

  58. SU - subquery unnesting

  59. OBYE - order by elimination

  60. OST - old style star transformation

  61. ST - new ( cbqt ) star transformation

  62. CNT - count ( col ) to count ( * ) transformation

  63. JE - Join Elimination

  64. JF - join factorization

  65. SLP - select list pruning

  66. DP - distinct placement

  67. qb - query block

  68. LB - leaf blocks

  69. DK - distinct keys

  70. LB/K - average number of leaf blocks per key

  71. DB/K - average number of data blocks per key

  72. CLUF - clustering factor

  73. NDV - number of distinct values

  74. Resp - response cost

  75. Card - cardinality

  76. Resc - resource cost

  77. NL - nested loops ( join )

  78. SM - sort merge ( join )

  79. HA - hash ( join )

  80. CPUSPEED - CPU Speed

  81. IOTFRSPEED - I/O transfer speed

  82. IOSEEKTIM - I/O seek time

  83. SREADTIM - average single block read time

  84. MREADTIM - average multiblock read time

  85. MBRC - average multiblock read count

  86. MAXTHR - maximum I/O system throughput

  87. SLAVETHR - average slave I/O throughput

  88. dmeth - distribution method

  89.   1 : no partitioning required

  90.   2 : value partitioned

  91.   4 : right is random ( round - robin )

  92.   128 : left is random ( round - robin )

  93.   8 : broadcast right and partition left

  94.   16 : broadcast left and partition right

  95.   32 : partition left using partitioning of right

  96.   64 : partition right using partitioning of left

  97.   256 : run the join in serial

  98.   0 : invalid distribution method

  99. sel - selectivity

  100. ptn - partition

  101. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  102. PARAMETERS USED BY THE OPTIMIZER

  103. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  104.    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  105.   PARAMETERS WITH ALTERED VALUES

  106.    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  107. Compilation Environment Dump

  108. Bug Fix Control Environment



  109.    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  110.   PARAMETERS WITH DEFAULT VALUES

  111.    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  112. Compilation Environment Dump

  113. optimizer_mode_hinted = false

  114. optimizer_features_hinted = 0 . .

  115. parallel_execution_enabled = true

  116. parallel_query_forced_dop = 0

  117. parallel_dml_forced_dop = 0

  118. parallel_ddl_forced_degree = 0

  119. parallel_ddl_forced_instances = 0

  120. _query_rewrite_fudge = 90

  121. optimizer_features_enable = 11 . 2 . . 3

  122. _optimizer_search_limit = 5

  123. cpu_count = 1

  124. active_instance_count = 1

  125. parallel_threads_per_cpu = 2

  126. hash_area_size = 131072

  127. bitmap_merge_area_size = 1048576

  128. sort_area_size = 65536

  129. sort_area_retained_size = 0

  130. _sort_elimination_cost_ratio = 0

  131. _optimizer_block_size = 8192

  132. _sort_multiblock_read_count = 2

  133. _hash_multiblock_io_count = 0

  134. _db_file_optimizer_read_count = 8

  135. _optimizer_max_permutations = 2000

  136. pga_aggregate_target = 286720 KB

  137. _pga_max_size = 204800 KB

  138. _query_rewrite_maxdisjunct = 257

  139. _smm_auto_min_io_size = 56 KB

  140. _smm_auto_max_io_size = 248 KB

  141. _smm_min_size = 286 KB

  142. _smm_max_size = 57344 KB

  143. _smm_px_max_size = 143360 KB

  144. _cpu_to_io = 0

  145. _optimizer_undo_cost_change = 11 . 2 . . 3

  146. parallel_query_mode = enabled

  147. parallel_dml_mode = disabled

  148. parallel_ddl_mode = enabled

  149. optimizer_mode = all_rows

  150. sqlstat_enabled = false

  151. _optimizer_percent_parallel = 101

  152. _always_anti_join = choose

  153. _always_semi_join = choose

  154. _optimizer_mode_force = true

  155. _partition_view_enabled = true

  156. _always_star_transformation = false

  157. _query_rewrite_or_error = false

  158. _hash_join_enabled = true

  159. cursor_sharing = exact

  160. _b_tree_bitmap_plans = true

  161. star_transformation_enabled = false

  162. _optimizer_cost_model = choose

  163. _new_sort_cost_estimate = true

  164. _complex_view_merging = true

  165. _unnest_subquery = true

  166. _eliminate_common_subexpr = true

  167. _pred_move_around = true

  168. _convert_set_to_join = false

  169. _push_join_predicate = true

  170. _push_join_union_view = true

  171. _fast_full_scan_enabled = true

  172. _optim_enhance_nnull_detection = true

  173. _parallel_broadcast_enabled = true

  174. _px_broadcast_fudge_factor = 100

  175. _ordered_nested_loop = true

  176. _no_or_expansion = false

  177. optimizer_index_cost_adj = 100

  178. optimizer_index_caching = 0

  179. _system_index_caching = 0

  180. _disable_datalayer_sampling = false

  181. query_rewrite_enabled = true

  182. query_rewrite_integrity = enforced

  183. _query_cost_rewrite = true

  184. _query_rewrite_2 = true

  185. _query_rewrite_1 = true

  186. _query_rewrite_expression = true

  187. _query_rewrite_jgmigrate = true

  188. _query_rewrite_fpc = true

  189. _query_rewrite_drj = true

  190. _full_pwise_join_enabled = true

  191. _partial_pwise_join_enabled = true

  192. _left_nested_loops_random = true

  193. _improved_row_length_enabled = true

  194. _index_join_enabled = true

  195. _enable_type_dep_selectivity = true

  196. _improved_outerjoin_card = true

  197. _optimizer_adjust_for_nulls = true

  198. _optimizer_degree = 0

  199. _use_column_stats_for_function = true

  200. _subquery_pruning_enabled = true

  201. _subquery_pruning_mv_enabled = false

  202. _or_expand_nvl_predicate = true

  203. _like_with_bind_as_equality = false

  204. _table_scan_cost_plus_one = true

  205. _cost_equality_semi_join = true

  206. _default_non_equality_sel_check = true

  207. _new_initial_join_orders = true

  208. _oneside_colstat_for_equijoins = true

  209. _optim_peek_user_binds = true

  210. _minimal_stats_aggregation = true

  211. _force_temptables_for_gsets = false

  212. workarea_size_policy = auto

  213. _smm_auto_cost_enabled = true

  214. _gs_anti_semi_join_allowed = true

  215. _optim_new_default_join_sel = true

  216. optimizer_dynamic_sampling = 2

  217. _pre_rewrite_push_pred = true

  218. _optimizer_new_join_card_computation = true

  219. _union_rewrite_for_gs = yes_gset_mvs

  220. _generalized_pruning_enabled = true

  221. _optim_adjust_for_part_skews = true

  222. _force_datefold_trunc = false

  223. statistics_level = typical

  224. _optimizer_system_stats_usage = true

  225. skip_unusable_indexes = true

  226. _remove_aggr_subquery = true

  227. _optimizer_push_down_distinct = 0

  228. _dml_monitoring_enabled = true

  229. _optimizer_undo_changes = false

  230. _predicate_elimination_enabled = true

  231. _nested_loop_fudge = 100

  232. _project_view_columns = true

  233. _local_communication_costing_enabled = true

  234. _local_communication_ratio = 50

  235. _query_rewrite_vop_cleanup = true

  236. _slave_mapping_enabled = true

  237. _optimizer_cost_based_transformation = linear

  238. _optimizer_mjc_enabled = true

  239. _right_outer_hash_enable = true

  240. _spr_push_pred_refspr = true

  241. _optimizer_cache_stats = false

  242. _optimizer_cbqt_factor = 50

  243. _optimizer_squ_bottomup = true

  244. _fic_area_size = 131072

  245. _optimizer_skip_scan_enabled = true

  246. _optimizer_cost_filter_pred = false

  247. _optimizer_sortmerge_join_enabled = true

  248. _optimizer_join_sel_sanity_check = true

  249. _mmv_query_rewrite_enabled = true

  250. _bt_mmv_query_rewrite_enabled = true

  251. _add_stale_mv_to_dependency_list = true

  252. _distinct_view_unnesting = false

  253. _optimizer_dim_subq_join_sel = true

  254. _optimizer_disable_strans_sanity_checks = 0

  255. _optimizer_compute_index_stats = true

  256. _push_join_union_view2 = true

  257. _optimizer_ignore_hints = false

  258. _optimizer_random_plan = 0

  259. _query_rewrite_setopgrw_enable = true

  260. _optimizer_correct_sq_selectivity = true

  261. _disable_function_based_index = false

  262. _optimizer_join_order_control = 3

  263. _optimizer_cartesian_enabled = true

  264. _optimizer_starplan_enabled = true

  265. _extended_pruning_enabled = true

  266. _optimizer_push_pred_cost_based = true

  267. _optimizer_null_aware_antijoin = true

  268. _optimizer_extend_jppd_view_types = true

  269. _sql_model_unfold_forloops = run_time

  270. _enable_dml_lock_escalation = false

  271. _bloom_filter_enabled = true

  272. _update_bji_ipdml_enabled = 0

  273. _optimizer_extended_cursor_sharing = udo

  274. _dm_max_shared_pool_pct = 1

  275. _optimizer_cost_hjsmj_multimatch = true

  276. _optimizer_transitivity_retain = true

  277. _px_pwg_enabled = true

  278. optimizer_secure_view_merging = true

  279. _optimizer_join_elimination_enabled = true

  280. flashback_table_rpi = non_fbt

  281. _optimizer_cbqt_no_size_restriction = true

  282. _optimizer_enhanced_filter_push = true

  283. _optimizer_filter_pred_pullup = true

  284. _rowsrc_trace_level = 0

  285. _simple_view_merging = true

  286. _optimizer_rownum_pred_based_fkr = true

  287. _optimizer_better_inlist_costing = all

  288. _optimizer_self_induced_cache_cost = false

  289. _optimizer_min_cache_blocks = 10

  290. _optimizer_or_expansion = depth

  291. _optimizer_order_by_elimination_enabled = true

  292. _optimizer_outer_to_anti_enabled = true

  293. _selfjoin_mv_duplicates = true

  294. _dimension_skip_null = true

  295. _force_rewrite_enable = false

  296. _optimizer_star_tran_in_with_clause = true

  297. _optimizer_complex_pred_selectivity = true

  298. _optimizer_connect_by_cost_based = true

  299. _gby_hash_aggregation_enabled = true

  300. _globalindex_pnum_filter_enabled = true

  301. _px_minus_intersect = true

  302. _fix_control_key = 0

  303. _force_slave_mapping_intra_part_loads = false

  304. _force_tmp_segment_loads = false

  305. _query_mmvrewrite_maxpreds = 10

  306. _query_mmvrewrite_maxintervals = 5

  307. _query_mmvrewrite_maxinlists = 5

  308. _query_mmvrewrite_maxdmaps = 10

  309. _query_mmvrewrite_maxcmaps = 20

  310. _query_mmvrewrite_maxregperm = 512

  311. _query_mmvrewrite_maxqryinlistvals = 500

  312. _disable_parallel_conventional_load = false

  313. _trace_virtual_columns = false

  314. _replace_virtual_columns = true

  315. _virtual_column_overload_allowed = true

  316. _kdt_buffering = true

  317. _first_k_rows_dynamic_proration = true

  318. _optimizer_sortmerge_join_inequality = true

  319. _optimizer_aw_stats_enabled = true

  320. _bloom_pruning_enabled = true

  321. result_cache_mode = MANUAL

  322. _px_ual_serial_input = true

  323. _optimizer_skip_scan_guess = false

  324. _enable_row_shipping = true

  325. _row_shipping_threshold = 80

  326. _row_shipping_explain = false

  327. transaction_isolation_level = read_commited

  328. _optimizer_distinct_elimination = true

  329. _optimizer_multi_level_push_pred = true

  330. _optimizer_group_by_placement = true

  331. _optimizer_rownum_bind_default = 10

  332. _enable_query_rewrite_on_remote_objs = true

  333. _optimizer_extended_cursor_sharing_rel = simple

  334. _optimizer_adaptive_cursor_sharing = true

  335. _direct_path_insert_features = 0

  336. _optimizer_improve_selectivity = true

  337. optimizer_use_pending_statistics = false

  338. _optimizer_enable_density_improvements = true

  339. _optimizer_aw_join_push_enabled = true

  340. _optimizer_connect_by_combine_sw = true

  341. _enable_pmo_ctas = 0

  342. _optimizer_native_full_outer_join = force

  343. _bloom_predicate_enabled = true

  344. _optimizer_enable_extended_stats = true

  345. _is_lock_table_for_ddl_wait_lock = 0

  346. _pivot_implementation_method = choose

  347. optimizer_capture_sql_plan_baselines = false

  348. optimizer_use_sql_plan_baselines = true

  349. _optimizer_star_trans_min_cost = 0

  350. _optimizer_star_trans_min_ratio = 0

  351. _with_subquery = OPTIMIZER

  352. _optimizer_fkr_index_cost_bias = 10

  353. _optimizer_use_subheap = true

  354. parallel_degree_policy = manual

  355. parallel_degree = 0

  356. parallel_min_time_threshold = 10

  357. _parallel_time_unit = 10

  358. _optimizer_or_expansion_subheap = true

  359. _optimizer_free_transformation_heap = true

  360. _optimizer_reuse_cost_annotations = true

  361. _result_cache_auto_size_threshold = 100

  362. _result_cache_auto_time_threshold = 1000

  363. _optimizer_nested_rollup_for_gset = 100

  364. _nlj_batching_enabled = 1

  365. parallel_query_default_dop = 0

  366. is_recur_flags = 0

  367. optimizer_use_invisible_indexes = false

  368. flashback_data_archive_internal_cursor = 0

  369. _optimizer_extended_stats_usage_control = 192

  370. _parallel_syspls_obey_force = true

  371. cell_offload_processing = true

  372. _rdbms_internal_fplib_enabled = false

  373. db_file_multiblock_read_count = 97

  374. _bloom_folding_enabled = true

  375. _mv_generalized_oj_refresh_opt = true

  376. cell_offload_compaction = ADAPTIVE

  377. cell_offload_plan_display = AUTO

  378. _bloom_predicate_pushdown_to_storage = true

  379. _bloom_vector_elements = 0

  380. _bloom_pushing_max = 512

  381. parallel_degree_limit = 65535

  382. parallel_force_local = false

  383. parallel_max_degree = 2

  384. total_cpu_count = 1

  385. _optimizer_coalesce_subqueries = true

  386. _optimizer_fast_pred_transitivity = true

  387. _optimizer_fast_access_pred_analysis = true

  388. _optimizer_unnest_disjunctive_subq = true

  389. _optimizer_unnest_corr_set_subq = true

  390. _optimizer_distinct_agg_transform = true

  391. _aggregation_optimization_settings = 0

  392. _optimizer_connect_by_elim_dups = true

  393. _optimizer_eliminate_filtering_join = true

  394. _connect_by_use_union_all = true

  395. dst_upgrade_insert_conv = true

  396. advanced_queuing_internal_cursor = 0

  397. _optimizer_unnest_all_subqueries = true

  398. parallel_autodop = 0

  399. parallel_ddldml = 0

  400. _parallel_cluster_cache_policy = adaptive

  401. _parallel_scalability = 50

  402. iot_internal_cursor = 0

  403. _optimizer_instance_count = 0

  404. _optimizer_connect_by_cb_whr_only = false

  405. _suppress_scn_chk_for_cqn = nosuppress_1466

  406. _optimizer_join_factorization = true

  407. _optimizer_use_cbqt_star_transformation = true

  408. _optimizer_table_expansion = true

  409. _and_pruning_enabled = true

  410. _deferred_constant_folding_mode = DEFAULT

  411. _optimizer_distinct_placement = true

  412. partition_pruning_internal_cursor = 0

  413. parallel_hinted = none

  414. _sql_compatibility = 0

  415. _optimizer_use_feedback = true

  416. _optimizer_try_st_before_jppd = true

  417. _dml_frequency_tracking = false

  418. _optimizer_interleave_jppd = true

  419. kkb_drop_empty_segments = 0

  420. _px_partition_scan_enabled = true

  421. _px_partition_scan_threshold = 64

  422. _optimizer_false_filter_pred_pullup = true

  423. _bloom_minmax_enabled = true

  424. only_move_row = 0

  425. _optimizer_enable_table_lookup_by_nl = true

  426. deferred_segment_creation = true

  427. _optimizer_filter_pushdown = true

  428. _allow_level_without_connect_by = false

  429. _max_rwgs_groupings = 8192

  430. _optimizer_outer_join_to_inner = true

  431. _optimizer_full_outer_join_to_outer = true

  432. _px_numa_support_enabled = true

  433. total_processor_group_count = 1


  434.    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  435.   PARAMETERS IN OPT_PARAM HINT

  436.    * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  437. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  438. Column Usage Monitoring is ON : tracking level = 1

  439. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


  440. Considering Query Transformations on query block SEL$1 ( # )

  441. * * * * * * * * * * * * * * * * * * * * * * * * * *

  442. Query transformations ( QT )

  443. * * * * * * * * * * * * * * * * * * * * * * * * * *

  444. JF : Checking validity of join factorization for query block SEL$2 ( # )

  445. JF : Bypassed : not a UNION or UNION - ALL query block .

  446. ST : not valid since star transformation parameter is FALSE

  447. TE : Checking validity of table expansion for query block SEL$2 ( # )

  448. TE : Bypassed : No partitioned table in query block .

  449. CBQT : Validity checks passed for dnkzmnvvdxgtm .

  450. CSE : Considering common sub - expression elimination in query block SEL$1 ( # )

  451. * * * * * * * * * * * * * * * * * * * * * * * * *

  452. Common Subexpression elimination ( CSE )

  453. * * * * * * * * * * * * * * * * * * * * * * * * *

  454. CSE : Considering common sub - expression elimination in query block SEL$2 ( # )

  455. * * * * * * * * * * * * * * * * * * * * * * * * *

  456. Common Subexpression elimination ( CSE )

  457. * * * * * * * * * * * * * * * * * * * * * * * * *

  458. CSE : CSE not performed on query block SEL$2 ( # ) .

  459. CSE : CSE not performed on query block SEL$1 ( # ) .

  460. OBYE : Considering Order - by Elimination from view SEL$1 ( # )

  461. * * * * * * * * * * * * * * * * * * * * * * * * * * *

  462. Order - by elimination ( OBYE )

  463. * * * * * * * * * * * * * * * * * * * * * * * * * * *

  464. OBYE : OBYE bypassed : no order by to eliminate .

  465. OJE : Begin : find best directive for query block SEL$1 ( # )

  466. OJE : End : finding best directive for query block SEL$1 ( # )

  467. OJE : Begin : find best directive for query block SEL$2 ( # )

  468. OJE : End : finding best directive for query block SEL$2 ( # )

  469. query block SEL$1 ( # ) unchanged

  470. Considering Query Transformations on query block SEL$1 ( # )

  471. * * * * * * * * * * * * * * * * * * * * * * * * * *

  472. Query transformations ( QT )

  473. * * * * * * * * * * * * * * * * * * * * * * * * * *

  474. CSE : Considering common sub - expression elimination in query block SEL$1 ( # )

  475. * * * * * * * * * * * * * * * * * * * * * * * * *

  476. Common Subexpression elimination ( CSE )

  477. * * * * * * * * * * * * * * * * * * * * * * * * *

  478. CSE : Considering common sub - expression elimination in query block SEL$2 ( # )

  479. * * * * * * * * * * * * * * * * * * * * * * * * *

  480. Common Subexpression elimination ( CSE )

  481. * * * * * * * * * * * * * * * * * * * * * * * * *

  482. CSE : CSE not performed on query block SEL$2 ( # ) .

  483. CSE : CSE not performed on query block SEL$1 ( # ) .

  484. query block SEL$1 ( # ) unchanged

  485. apadrv - start sqlid = 15729934021953503027

  486.    :

  487.      call ( in - use = 1832 , alloc = 16344 ) , compile ( in - use = 62144 , alloc = 62632 ) , execution ( in - use = 3456 , alloc = 4032 )


  488. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  489. Peeked values of the binds in SQL statement

  490. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


  491. CBQT : Considering cost - based transformation on query block SEL$1 ( # )

  492. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  493. COST - BASED QUERY TRANSFORMATIONS

  494. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  495. FPD : Considering simple filter push ( pre rewrite ) in query block SEL$2 ( # )

  496. FPD : Current where clause predicates \ "EMP\" . \ "SAL\" > 3000


  497. FPD : Considering simple filter push ( pre rewrite ) in query block SEL$1 ( # )

  498. FPD : Current where clause predicates \ "DEPT\" . \ "DEPTNO\" = ANY ( SELECT \ "EMP\" . \ "DEPTNO\" FROM \ "EMP\" \ "EMP\" )


  499. OBYE : Considering Order - by Elimination from view SEL$1 ( # )

  500. * * * * * * * * * * * * * * * * * * * * * * * * * * *

  501. Order - by elimination ( OBYE )

  502. * * * * * * * * * * * * * * * * * * * * * * * * * * *

  503. OBYE : OBYE bypassed : no order by to eliminate .

  504. Considering Query Transformations on query block SEL$1 ( # )

  505. * * * * * * * * * * * * * * * * * * * * * * * * * *

  506. Query transformations ( QT )

  507. * * * * * * * * * * * * * * * * * * * * * * * * * *

  508. CSE : Considering common sub - expression elimination in query block SEL$1 ( # )

  509. * * * * * * * * * * * * * * * * * * * * * * * * *

  510. Common Subexpression elimination ( CSE )

  511. * * * * * * * * * * * * * * * * * * * * * * * * *

  512. CSE : Considering common sub - expression elimination in query block SEL$2 ( # )

  513. * * * * * * * * * * * * * * * * * * * * * * * * *

  514. Common Subexpression elimination ( CSE )

  515. * * * * * * * * * * * * * * * * * * * * * * * * *

  516. CSE : CSE not performed on query block SEL$2 ( # ) .

  517. CSE : CSE not performed on query block SEL$1 ( # ) .

  518. kkqctdrvTD - start on query block SEL$1 ( # )

  519. kkqctdrvTD - start : :

  520.      call ( in - use = 1832 , alloc = 16344 ) , compile ( in - use = 104584 , alloc = 108008 ) , execution ( in - use = 3456 , alloc = 4032 )


  521. Registered qb : SEL$1 0x576c9f98 ( COPY SEL$1 )

  522. - - - - - - - - - - - - - - - - - - - - -

  523. QUERY BLOCK SIGNATURE

  524. - - - - - - - - - - - - - - - - - - - - -

  525.   signature ( ) : NULL

  526. Registered qb : SEL$2 0x576ca878 ( COPY SEL$2 )

  527. - - - - - - - - - - - - - - - - - - - - -

  528. QUERY BLOCK SIGNATURE

  529. - - - - - - - - - - - - - - - - - - - - -

  530.   signature ( ) : NULL

  531. * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  532. Cost - Based Subquery Unnesting

  533. * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  534. SU : Unnesting query blocks in query block SEL$1 ( # 1 ) that are valid to unnest .

  535. Subquery removal for query block SEL$2 ( # 2 )

  536. RSW : Not valid for subquery removal SEL$2 ( # 2 )

  537. Subquery unchanged .

  538. Subquery Unnesting on query block SEL$1 ( # 1 ) SU : Performing unnesting that does not require costing .

  539. SU : Considering subquery unnest on query block SEL$1 ( # 1 ) .

  540. SU : Checking validity of unnesting subquery SEL$2 ( # 2 )

  541. SU : Passed validity checks .

  542. SU : Transforming ANY subquery to a join .

  543. Registered qb : SEL$5DA710D3 0x576c9f98 ( SUBQUERY UNNEST SEL$1 ; SEL$2 )

  544. - - - - - - - - - - - - - - - - - - - - -

  545. QUERY BLOCK SIGNATURE

  546. - - - - - - - - - - - - - - - - - - - - -

  547.   signature ( ) : qb_name = SEL$5DA710D3 nbfros = 2 flg =

  548.     fro ( ) : flg = 0 objn = 75333 hint_alias = \ "DEPT\" @ \ "SEL$1\"

  549.     fro ( 1 ) : flg = 0 objn = 75335 hint_alias = \ "EMP\" @ \ "SEL$2\"


  550. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  551. Cost - Based Complex View Merging

  552. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  553. CVM : Finding query blocks in query block SEL$5DA710D3 ( # 1 ) that are valid to merge .

  554. OJE : Begin : find best directive for query block SEL$5DA710D3 ( # 1 )

  555. OJE : End : finding best directive for query block SEL$5DA710D3 ( # 1 )

  556. kkqctdrvTD - cleanup : transform ( in - use = 4792 , alloc = 8392 ) :

  557.      call ( in - use = 2512 , alloc = 16344 ) , compile ( in - use = 120856 , alloc = 131696 ) , execution ( in - use = 3496 , alloc = 4032 )


  558. kkqctdrvTD - end :

  559.      call ( in - use = 2512 , alloc = 16344 ) , compile ( in - use = 112680 , alloc = 131696 ) , execution ( in - use = 3496 , alloc = 4032 )


  560. Subquery removal for query block SEL$2 ( # 2 )

  561. RSW : Not valid for subquery removal SEL$2 ( # 2 )

  562. Subquery unchanged .

  563. SU : Transforming ANY subquery to a join .

  564. SJC : Considering set - join conversion in query block SEL$5DA710D3 ( # 1 )

  565. * * * * * * * * * * * * * * * * * * * * * * * * *

  566. Set - Join Conversion ( SJC )

  567. * * * * * * * * * * * * * * * * * * * * * * * * *

  568. SJC : not performed

  569. OJE : Begin : find best directive for query block SEL$5DA710D3 ( # 1 )

  570. OJE : End : finding best directive for query block SEL$5DA710D3 ( # 1 )

  571. JE : Considering Join Elimination on query block SEL$5DA710D3 ( # 1 )

  572. * * * * * * * * * * * * * * * * * * * * * * * * *

  573. Join Elimination ( JE )

  574. * * * * * * * * * * * * * * * * * * * * * * * * *

  575. SQL : * * * * * * * UNPARSED QUERY IS * * * * * * *

  576. SELECT DEPT . DEPTNO   DEPTNO , DEPT . DNAME   DNAME , DEPT . LOC   LOC  FROM SCOTT . EMP   EMP , SCOTT . DEPT   DEPT  WHERE DEPT . DEPTNO = EMP . DEPTNO   AND EMP . SAL > 3000

  577. JE : cfro : EMP objn : 75333 col# : 8 dfro : DEPT dcol# : 1

  578. JE : cfro : EMP objn : 75333 col# : 8 dfro : DEPT dcol# : 1

  579. JE : cfro : EMP objn : 75333 col# : 8 dfro : DEPT dcol# : 1

  580. JE : cfro : EMP objn : 75333 col# : 8 dfro : DEPT dcol# : 1

  581. JE : cfro : DEPT objn : 75335 col# : 1 dfro : EMP dcol# : 8

  582. SQL : * * * * * * * UNPARSED QUERY IS * * * * * * *

  583. SELECT DEPT . DEPTNO   DEPTNO , DEPT . DNAME   DNAME , DEPT . LOC   LOC  FROM SCOTT . EMP   EMP , SCOTT . DEPT   DEPT  WHERE DEPT . DEPTNO = EMP . DEPTNO   AND EMP . SAL > 3000

  584. Query block SEL$5DA710D3 ( # 1 ) unchanged

  585. PM : Considering predicate move - around in query block SEL$5DA710D3 ( # 1 )

  586. * * * * * * * * * * * * * * * * * * * * * * * * * *

  587. Predicate Move - Around ( PM )

  588. * * * * * * * * * * * * * * * * * * * * * * * * * *

  589. PM : PM bypassed : Outer query contains no views .

  590. PM : PM bypassed : Outer query contains no views .

  591. kkqctdrvTD - start on query block SEL$5DA710D3 ( # 1 )

  592. kkqctdrvTD - start : :

  593.      call ( in - use = 3568 , alloc = 16344 ) , compile ( in - use = 114000 , alloc = 131696 ) , execution ( in - use = 3704 , alloc = 4032 )


  594. kkqctdrvTD - cleanup : transform ( in - use = , alloc = ) :

  595.      call ( in - use = 3568 , alloc = 16344 ) , compile ( in - use = 114632 , alloc = 131696 ) , execution ( in - use = 3704 , alloc = 4032 )


  596. kkqctdrvTD - end :

  597.      call ( in - use = 3568 , alloc = 16344 ) , compile ( in - use = 114952 , alloc = 131696 ) , execution ( in - use = 3704 , alloc = 4032 )


  598. kkqctdrvTD - start on query block SEL$5DA710D3 ( # 1 )

  599. kkqctdrvTD - start : :

  600.      call ( in - use = 3568 , alloc = 16344 ) , compile ( in - use = 114952 , alloc = 131696 ) , execution ( in - use = 3704 , alloc = 4032 )


  601. kkqctdrvTD - cleanup : transform ( in - use = , alloc = ) :

  602.      call ( in - use = 3568 , alloc = 16344 ) , compile ( in - use = 115560 , alloc = 131696 ) , execution ( in - use = 3704 , alloc = 4032 )


  603. kkqctdrvTD - end :

  604.      call ( in - use = 3568 , alloc = 16344 ) , compile ( in - use = 115880 , alloc = 131696 ) , execution ( in - use = 3704 , alloc = 4032 )


  605. kkqctdrvTD - start on query block SEL$5DA710D3 ( # 1 )

  606. kkqctdrvTD - start : :

  607.      call ( in - use = 3568 , alloc = 16344 ) , compile ( in - use = 115880 , alloc = 131696 ) , execution ( in - use = 3704 , alloc = 4032 )


  608. TE : Checking validity of table expansion for query block SEL$5DA710D3 ( # 1 )

  609. TE : Bypassed : No partitioned table in query block .

  610. kkqctdrvTD - cleanup : transform ( in - use = , alloc = ) :

  611.      call ( in - use = 3568 , alloc = 16344 ) , compile ( in - use = 116488 , alloc = 131696 ) , execution ( in - use = 3704 , alloc = 4032 )


  612. kkqctdrvTD - end :

  613.      call ( in - use = 3568 , alloc = 16344 ) , compile ( in - use = 116808 , alloc = 131696 ) , execution ( in - use = 3704 , alloc = 4032 )


  614. TE : Checking validity of table expansion for query block SEL$5DA710D3 ( # 1 )

  615. TE : Bypassed : No partitioned table in query block .

  616. ST : Query in kkqstardrv : * * * * * * * UNPARSED QUERY IS * * * * * * *

  617. SELECT DEPT . DEPTNO   DEPTNO , DEPT . DNAME   DNAME , DEPT . LOC   LOC  FROM SCOTT . EMP   EMP , SCOTT . DEPT   DEPT  WHERE DEPT . DEPTNO = EMP . DEPTNO   AND EMP . SAL > 3000

  618. ST : not valid since star transformation parameter is FALSE

  619. kkqctdrvTD - start on query block SEL$5DA710D3 ( # 1 )

  620. kkqctdrvTD - start : :

  621.      call ( in - use = 3664 , alloc = 16344 ) , compile ( in - use = 116808 , alloc = 131696 ) , execution ( in - use = 3704 , alloc = 4032 )


  622. JF : Checking validity of join factorization for query block SEL$5DA710D3 ( # 1 )

  623. JF : Bypassed : not a UNION or UNION - ALL query block .

  624. kkqctdrvTD - cleanup : transform ( in - use = , alloc = ) :

  625.      call ( in - use = 3664 , alloc = 16344 ) , compile ( in - use = 117416 , alloc = 131696 ) , execution ( in - use = 3704 , alloc = 4032 )


  626. kkqctdrvTD - end :

  627.      call ( in - use = 3664 , alloc = 16344 ) , compile ( in - use = 117736 , alloc = 131696 ) , execution ( in - use = 3704 , alloc = 4032 )


  628. JPPD : Considering Cost - based predicate pushdown from query block SEL$5DA710D3 ( # 1 )

  629. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  630. Cost - based predicate pushdown ( JPPD )

  631. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  632. kkqctdrvTD - start on query block SEL$5DA710D3 ( # 1 )

  633. kkqctdrvTD - start : :

  634.      call ( in - use = 3664 , alloc = 16344 ) , compile ( in - use = 117736 , alloc = 131696 ) , execution ( in - use = 3704 , alloc = 4032 )


  635. kkqctdrvTD - cleanup : transform ( in - use = , alloc = ) :

  636.      call ( in - use = 3664 , alloc = 16344 ) , compile ( in - use = 118344 , alloc = 131696 ) , execution ( in - use = 3704 , alloc = 4032 )


  637. kkqctdrvTD - end :

  638.      call ( in - use = 3664 , alloc = 16344 ) , compile ( in - use = 118664 , alloc = 131696 ) , execution ( in - use = 3704 , alloc = 4032 )


  639. JPPD : Applying transformation directives

  640. query block SEL$1 transformed to SEL$5DA710D3 ( # 1 )

  641. FPD : Considering simple filter push in query block SEL$5DA710D3 ( # 1 )

  642. DEPT . DEPTNO = EMP . DEPTNO   AND EMP . SAL > 3000

  643. try to generate transitive predicate from check constraints for query block SEL$5DA710D3 ( # 1 )

  644. finally : DEPT . DEPTNO = EMP . DEPTNO   AND EMP . SAL > 3000


  645. Final query after transformations : * * * * * * * UNPARSED QUERY IS * * * * * * *

  646. SELECT DEPT . DEPTNO   DEPTNO, DEPT . DNAME   DNAME , DEPT . LOC   LOC  FROM SCOTT . EMP   EMP , SCOTT . DEPT   DEPT  WHERE DEPT . DEPTNO = EMP . DEPTNO   AND EMP . SAL > 3000

  647. kkoqbc : optimizing query block SEL$5DA710D3 ( # 1 )

  648.         

  649.          :

  650.      call ( in - use = 3952 , alloc = 16344 ) , compile ( in - use = 119968 , alloc = 131696 ) , execution ( in - use = 3704 , alloc = 4032 )


  651. kkoqbc - subheap ( create addr = 0x2b265763a658 )

  652. * * * * * * * * * * * * * * * *

  653. QUERY BLOCK TEXT

  654. * * * * * * * * * * * * * * * *

  655. select * from dept where deptno in ( select deptno from emp where sal > 3000 )

  656. - - - - - - - - - - - - - - - - - - - - -

  657. QUERY BLOCK SIGNATURE

  658. - - - - - - - - - - - - - - - - - - - - -

  659. signature ( optimizer ) : qb_name = SEL$5DA710D3 nbfros = 2 flg =

  660.   fro ( ) : flg = 0 objn = 75333 hint_alias = \ "DEPT\" @ \ "SEL$1\"

  661.   fro ( 1 ) : flg = 0 objn = 75335 hint_alias = \ "EMP\" @ \ "SEL$2\"


  662. - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  663. SYSTEM STATISTICS INFORMATION

  664. - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  665.   Using NOWORKLOAD Stats

  666.   CPUSPEEDNW : 1752 millions instructions/sec ( default is 100 )

  667.   IOTFRSPEED : 4096 bytes per millisecond ( default is 4096 )

  668.   IOSEEKTIM : 10 milliseconds ( default is 10 )

  669.   MBRC : NO VALUE blocks ( default is 8 )


  670. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  671. BASE STATISTICAL INFORMATION

  672. * * * * * * * * * * * * * * * * * * * * * * *

  673. Table Stats : :

  674.   Table : DEPT  Alias : DEPT

  675.     #Rows : 4  #Blks : 5  AvgRowLen : 20 . 00  ChainCnt : 0 . 00

  676.   Column ( # 1 ) : DEPTNO (

  677.     AvgLen : 3 NDV : 4 Nulls : 0 Density : 0 . 250000 Min : 10 Max : 40

  678. Index Stats : :

  679.   Index : PK_DEPT  Col# : 1

  680.     LVLS : 0  #LB : 1  #DK : 4  LB/K : 1 . 00  DB/K : 1 . 00  CLUF : 1 . 00

  681. * * * * * * * * * * * * * * * * * * * * * * *

  682. Table Stats : :

  683.   Table : EMP  Alias : EMP

  684.     #Rows : 14  #Blks : 5  AvgRowLen : 38 . 00  ChainCnt : 0 . 00

  685.   Column ( # 8 ) : DEPTNO (

  686.     AvgLen : 3 NDV : 3 Nulls : 0 Density : 0 . 333333 Min : 10 Max : 30

  687. Index Stats : :

  688.   Index : PK_EMP  Col# : 1

  689.     LVLS : 0  #LB : 1  #DK : 14  LB/K : 1 . 00  DB/K : 1 . 00  CLUF : 1 . 00

  690. Access path analysis for EMP

  691. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  692. SINGLE TABLE ACCESS PATH

  693.   Single Table Cardinality Estimation for EMP [ EMP ]

  694.   Column ( # 6 ) : SAL (

  695.     AvgLen : 4 NDV : 12 Nulls : 0 Density : 0 . 083333 Min : 800 Max : 5000

  696.   Table : EMP  Alias : EMP

  697.     Card : Original : 14 . 000000  Rounded : 7  Computed : 6 . 67  Non Adjusted : 6 . 67

  698.   Access Path : TableScan

  699.     Cost : 3 . 00  Resp : 3 . 00  Degree : 0

  700.       Cost_io : 3 . 00  Cost_cpu : 40087

  701.       Resp_io : 3 . 00  Resp_cpu : 40087

  702.   Best : : AccessPath : TableScan

  703.          Cost : 3 . 00  Degree : 1  Resp : 3 . 00  Card : 6 . 67  Bytes : 0


  704. Access path analysis for DEPT

  705. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  706. SINGLE TABLE ACCESS PATH

  707.   Single Table Cardinality Estimation for DEPT [ DEPT ]

  708.   Table : DEPT  Alias : DEPT

  709.     Card : Original : 4 . 000000  Rounded : 4  Computed : 4 . 00  Non Adjusted : 4 . 00

  710.   Access Path : TableScan

  711.     Cost : 3 . 00  Resp : 3 . 00  Degree : 0

  712.       Cost_io : 3 . 00  Cost_cpu : 36367

  713.       Resp_io : 3 . 00  Resp_cpu : 36367

  714.   Best : : AccessPath : TableScan

  715.          Cost : 3 . 00  Degree : 1  Resp : 3 . 00  Card : 4 . 00  Bytes : 0


  716. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *



  717. OPTIMIZER STATISTICS AND COMPUTATIONS

  718. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  719. GENERAL PLANS

  720. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  721. Considering cardinality - based initial join order .

  722. Permutations for Starting Table :

  723. Join order [ 1 ] : DEPT [ DEPT ] # 0  EMP [ EMP ] # 1


  724. * * * * * * * * * * * * * * *

  725. Now joining : EMP [ EMP ] # 1

  726. * * * * * * * * * * * * * * *

  727. NL Join

  728.   Outer table : Card : 4 . 00  Cost : 3 . 00  Resp : 3 . 00  Degree : 1  Bytes : 20

  729. Access path analysis for EMP

  730.   Inner table : EMP  Alias : EMP

  731.   Access Path : TableScan

  732.     NL Join : Cost : 10 . 01  Resp : 10 . 01  Degree : 1

  733.       Cost_io : 10 . 00  Cost_cpu : 197836

  734.       Resp_io : 10 . 00  Resp_cpu : 197836


  735.   Best NL cost : 10 . 01

  736.           resc : 10 . 01  resc_io : 10 . 00  resc_cpu : 197836

  737.           resp : 10 . 01  resp_io : 10 . 00  resc_cpu : 197836

  738. > > > adjusting AJ/SJ sel based on min/max ranges : jsel = min ( . 750000 , 0 . 666667 )

  739. Semi Join Card : 2 . 666667 = outer ( 4 . 000000 ) * sel ( . 666667 )

  740. Join Card - Rounded : 3 Computed : 2 . 67

  741.   Outer table : DEPT  Alias : DEPT

  742.     resc : 3 . 00  card 4 . 00  bytes : 20  deg : 1  resp : 3 . 00

  743.   Inner table : EMP  Alias : EMP

  744.     resc : 3 . 00  card : 6 . 67  bytes : 7  deg : 1  resp : 3 . 00

  745.     using dmeth : 2  #groups : 1

  746.     SORT ressource         Sort statistics

  747.       Sort width : 334 Area size : 292864 Max Area size : 58720256

  748.       Degree : 1

  749.       Blocks to Sort : 1 Row size : 32 Total Rows : 4

  750.       Initial runs : 1 Merge passes : 0 IO Cost / pass : 0

  751.       Total IO sort cost : 0      Total CPU sort cost : 21021466

  752.       Total Temp space used : 0

  753.     SORT ressource         Sort statistics

  754.       Sort width : 334 Area size : 292864 Max Area size : 58720256

  755.       Degree : 1

  756.       Blocks to Sort : 1 Row size : 18 Total Rows : 7

  757.       Initial runs : 1 Merge passes : 0 IO Cost / pass : 0

  758.       Total IO sort cost : 0      Total CPU sort cost : 21021991

  759.       Total Temp space used : 0

  760.   SM join : Resc : 8 . 00  Resp : 8 . 00 [ multiMatchCost = . 00 ]

  761. SM Join

  762.   SM cost : 8 . 00

  763.      resc : 8 . 00 resc_io : 6 . 00 resc_cpu : 42119911

  764.      resp : 8 . 00 resp_io : 6 . 00 resp_cpu : 42119911

  765. SM Join ( with index on outer )

  766.   Access Path : index ( FullScan )

  767.     Index : PK_DEPT

  768.     resc_io : 2 . 00  resc_cpu : 15803

  769.     ix_sel : 1 . 000000  ix_sel_with_filters : 1 . 000000

  770.     Cost : 2 . 00  Resp : 2 . 00  Degree : 1

  771.   Outer table : DEPT  Alias : DEPT

  772.     resc : 2 . 00  card 4 . 00  bytes : 20  deg : 1  resp : 2 . 00

  773.   Inner table : EMP  Alias : EMP

  774.     resc : 3 . 00  card : 6 . 67  bytes : 7  deg : 1  resp : 3 . 00

  775.     using dmeth : 2  #groups : 1

  776.     SORT ressource         Sort statistics

  777.       Sort width : 334 Area size : 292864 Max Area size : 58720256

  778.       Degree : 1

  779.       Blocks to Sort : 1 Row size : 18 Total Rows : 7

  780.       Initial runs : 1 Merge passes : 0 IO Cost / pass : 0

  781.       Total IO sort cost : 0      Total CPU sort cost : 21021991

  782.       Total Temp space used : 0

  783.   SM join : Resc : 6 . 00  Resp : 6 . 00 [ multiMatchCost = . 00 ]

  784.   Outer table : DEPT  Alias : DEPT

  785.     resc : 3 . 00  card 4 . 00  bytes : 20  deg : 1  resp : 3 . 00

  786.   Inner table : EMP  Alias : EMP

  787.     resc : 3 . 00  card : 6 . 67  bytes : 7  deg : 1  resp : 3 . 00

  788.     using dmeth : 2  #groups : 1

  789.     Cost per ptn : 0 . 50  #ptns : 1

  790.     hash_area : 124 ( max = 14336 ) buildfrag : 1  probefrag : 1  ppasses : 1

  791.   Hash join : Resc : 6 . 50  Resp : 6 . 50 [ multiMatchCost = . 00 ]

  792. HA Join

  793.   HA cost : 6 . 50

  794.      resc : 6 . 50 resc_io : 6 . 00 resc_cpu : 10588307

  795.      resp : 6 . 50 resp_io : 6 . 00 resp_cpu : 10588307

  796. Best : : JoinMethod : SortMergeSemi

  797.        Cost : 6 . 00  Degree : 1  Resp : 6 . 00  Card : 2 . 67 Bytes : 27

  798. * * * * * * * * * * * * * * * * * * * * * * *

  799. Best so far : Table# : 0  cost : 2 . 0008  card : 4 . 0000  bytes : 80

  800.               Table# : 1  cost : 6 . 0027  card : 2 . 6667  bytes : 81

  801. * * * * * * * * * * * * * * * * * * * * * * *

  802. Join order [ 2 ] : EMP [ EMP ] # 1  DEPT [ DEPT ] #

  803.     SORT ressource         Sort statistics

  804.       Sort width : 334 Area size : 292864 Max Area size : 58720256

  805.       Degree : 1

  806.       Blocks to Sort : 1 Row size : 18 Total Rows : 7

  807.       Initial runs : 1 Merge passes : 0 IO Cost / pass : 0

  808.       Total IO sort cost : 0      Total CPU sort cost : 21021991

  809.       Total Temp space used : 0


  810. * * * * * * * * * * * * * * *

  811. Now joining : DEPT [ DEPT ] #

  812. * * * * * * * * * * * * * * *

  813. NL Join

  814.   Outer table : Card : 3 . 00  Cost : 4 . 00  Resp : 4 . 00  Degree : 1  Bytes : 7

  815. Access path analysis for DEPT

  816.   Inner table : DEPT  Alias : DEPT

  817.   Access Path : TableScan

  818.     NL Join : Cost : 10 . 01  Resp : 10 . 01  Degree : 1

  819.       Cost_io : 9 . 00  Cost_cpu : 21171180

  820.       Resp_io : 9 . 00  Resp_cpu : 21171180

  821.   Access Path : index ( UniqueScan )

  822.     Index : PK_DEPT

  823.     resc_io : 1 . 00  resc_cpu : 8361

  824.     ix_sel : 0 . 250000  ix_sel_with_filters : 0 . 250000

  825.     NL Join : Cost : 7 . 00  Resp : 7 . 00  Degree : 1

  826.       Cost_io : 6 . 00  Cost_cpu : 21087162

  827.       Resp_io : 6 . 00  Resp_cpu : 21087162

  828.   Access Path : index ( AllEqUnique )

  829.     Index : PK_DEPT

  830.     resc_io : 1 . 00  resc_cpu : 8361

  831.     ix_sel : 0 . 250000  ix_sel_with_filters : 0 . 250000

  832.     NL Join : Cost : 7 . 00  Resp : 7 . 00  Degree : 1

  833.       Cost_io : 6 . 00  Cost_cpu : 21087162

  834.       Resp_io : 6 . 00  Resp_cpu : 21087162


  835.   Best NL cost : 7 . 00

  836.           resc : 7 . 00  resc_io : 6 . 00  resc_cpu : 21087162

  837.           resp : 7 . 00  resp_io : 6 . 00  resc_cpu : 21087162

  838. Join Card : 3 . 000000 = outer ( 3 . 000000 ) * inner ( 4 . 000000 ) * sel ( . 250000 )

  839. Join Card - Rounded : 3 Computed : 3 . 00

  840.   Outer table : EMP  Alias : EMP

  841.     resc : 4 . 00  card 3 . 00  bytes : 7  deg : 1  resp : 4 . 00

  842.   Inner table : DEPT  Alias : DEPT

  843.     resc : 3 . 00  card : 4 . 00  bytes : 20  deg : 1  resp : 3 . 00

  844.     using dmeth : 2  #groups : 1

  845.     SORT ressource         Sort statistics

  846.       Sort width : 334 Area size : 292864 Max Area size : 58720256

  847.       Degree : 1

  848.       Blocks to Sort : 1 Row size : 18 Total Rows : 3

  849.       Initial runs : 1 Merge passes : 0 IO Cost / pass : 0

  850.       Total IO sort cost : 0      Total CPU sort cost : 21021320

  851.       Total Temp space used : 0

  852.     SORT ressource         Sort statistics

  853.       Sort width : 334 Area size : 292864 Max Area size : 58720256

  854.       Degree : 1

  855.       Blocks to Sort : 1 Row size : 32 Total Rows : 4

  856.       Initial runs : 1 Merge passes : 0 IO Cost / pass : 0

  857.       Total IO sort cost : 0      Total CPU sort cost : 21021466

  858.       Total Temp space used : 0

  859.   SM join : Resc : 9 . 00  Resp : 9 . 00 [ multiMatchCost = . 00 ]

  860. SM Join

  861.   SM cost : 9 . 00

  862.      resc : 9 . 00 resc_io : 6 . 00 resc_cpu : 63141231

  863.      resp : 9 . 00 resp_io : 6 . 00 resp_cpu : 63141231

  864.   Outer table : EMP  Alias : EMP

  865.     resc : 4 . 00  card 3 . 00  bytes : 7  deg : 1  resp : 4 . 00

  866.   Inner table : DEPT  Alias : DEPT

  867.     resc : 3 . 00  card : 4 . 00  bytes : 20  deg : 1  resp : 3 . 00

  868.     using dmeth : 2  #groups : 1

  869.     Cost per ptn : 0 . 50  #ptns : 1

  870.     hash_area : 124 ( max = 14336 ) buildfrag : 1  probefrag : 1  ppasses : 1

  871.   Hash join : Resc : 7 . 50  Resp : 7 . 50 [ multiMatchCost = . 00 ]

  872. HA Join

  873.   HA cost : 7 . 50

  874.      resc : 7 . 50 resc_io : 6 . 00 resc_cpu : 31609848

  875.      resp : 7 . 50 resp_io : 6 . 00 resp_cpu : 31609848

  876. Plan cardinality mismatch : best card = 2 . 66666666667   curr card = 3 . 00000000000

  877. Join order aborted : cost > best plan cost

  878. * * * * * * * * * * * * * * * * * * * * * * *

  879. ( newjo - stop - 1 ) k : , spcnt : , perm : 2 , maxperm : 2000


  880. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  881. Number of join permutations tried : 2

  882. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  883. Consider using bloom filter between DEPT [ DEPT ] and EMP [ EMP ] with ? ?

  884. kkoBloomFilter : join ( lcdn : 4 rcdn : 7 jcdn : 3 limit : 13 )

  885. Computing bloom ndv for creator : DEPT [ DEPT ] ccdn : 4 . 0 and user : EMP [ EMP ] ucdn : 6 . 7

  886. kkopqComputeBloomNdv : predicate ( bndv : 4 ndv : 4 ) and ( bndv : 3 ndv : 3 )

  887. kkopqComputeBloomNdv : pred cnt : 2 ndv : 4 reduction : 1

  888. kkoBloomFilter : join ndv : 0 reduction : . 600000 ( limit : . 500000 ) rejected because distinct value ratio

  889. Enumerating distribution method ( advanced )

  890. - - - Distribution method for

  891. join between DEPT [ DEPT ] ( serial ) and EMP [ EMP ] ( serial ) ; jm = 8 ; right side access path = TableScan

  892. - - - - serial Sort - Merge - Join - > NONE


  893. ( newjo - save ) [ 0 1 ]

  894. Trying or - Expansion on query block SEL$5DA710D3 ( # 1 )

  895. Transfer Optimizer annotations for query block SEL$5DA710D3 ( # 1 )

  896. id = 0 frofkksm [ i ] ( sort - merge/hash ) predicate = DEPT . DEPTNO = EMP . DEPTNO

  897. id = 0 frosand ( sort - merge/hash ) predicate = DEPT . DEPTNO = EMP . DEPTNO

  898. id = 0 frofand predicate = EMP . SAL > 3000

  899. Final cost for query block SEL$5DA710D3 ( # 1 ) - All Rows Plan :

  900.   Best join order : 1

  901.   Cost : 6 . 0027  Degree : 1  Card : 3 . 0000  Bytes : 81

  902.   Resc : 6 . 0027  Resc_io : 5 . 0000  Resc_cpu : 21077881

  903.   Resp : 6 . 0027  Resp_io : 5 . 0000  Resc_cpu : 21077881

  904. kkoqbc - subheap ( delete addr = 0x2b265763a658 , in - use = 26368 , alloc = 32840 )

  905. kkoqbc - end :

  906.          :

  907.      call ( in - use = 19256 , alloc = 65656 ) , compile ( in - use = 123008 , alloc = 131696 ) , execution ( in - use = 3704 , alloc = 4032 )


  908. kkoqbc : finish optimizing query block SEL$5DA710D3 ( # 1 )

  909. apadrv - end

  910.            :

  911.      call ( in - use = 19256 , alloc = 65656 ) , compile ( in - use = 124008 , alloc = 131696 ) , execution ( in - use = 3704 , alloc = 4032 )



  912. Starting SQL statement dump


  913. user_id = 83 user_name = SCOTT module = SQL * Plus action =

  914. sql_id = dnkzmnvvdxgtm plan_hash_value = 1090737117 problem_type = 3

  915. - - - - - Current SQL Statement for this session ( sql_id = dnkzmnvvdxgtm ) - - - - -

  916. select * from dept where deptno in ( select deptno from emp where sal > 3000 )

  917. sql_text_length = 77

  918. sql = select * from dept where deptno in ( select deptno from emp where sal > 3000 )

  919. - - - - - Explain Plan Dump - - - - -

  920. - - - - - Plan Table - - - - -

  921.  

  922. = = = = = = = = = = = =

  923. Plan Table

  924. = = = = = = = = = = = =

  925. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +

  926. | Id   | Operation                      | Name    |   Rows | Bytes |    Cost |      Time |

  927. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +

  928. | 0    | SELECT STATEMENT               |           |       |         |       6 |            |

  929. | 1   |   MERGE JOIN SEMI               |           |      3 |    81 |       6 | 00 : 00 : 01 |

  930. | 2    |    TABLE ACCESS BY INDEX ROWID | DEPT     |      4 |     80 |       2 | 00 : 00 : 01 |

  931. | 3    |     INDEX FULL SCAN             | PK_DEPT |      4 |         |       1 | 00 : 00 : 01 |

  932. | 4    |   SORT UNIQUE                  |           |      7 |    49 |       4 | 00 : 00 : 01 |

  933. | 5    |     TABLE ACCESS FULL           | EMP      |      7 |     49 |       3 | 00 : 00 : 01 |

  934. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +

  935. Predicate Information :

  936. - - - - - - - - - - - - - - - - - - - - - -

  937. 4 - access ( "DEPTNO" = "DEPTNO" )     ---變成了join 條件就是它

  938. 4 - filter ( "DEPTNO" = "DEPTNO" )

  939. 5 - filter ( "SAL" > 3000 )

  940.  

  941. Content of other_xml column

  942. = = = = = = = = = = = = = = = = = = = = = = = = = = =

  943.   db_version : 11 . 2 . . 3

  944.   parse_schema : SCOTT

  945.   plan_hash : 1090737117

  946.   plan_hash_2 : 1551854233

  947.   Outline Data :

  948.   / * +

  949.     BEGIN_OUTLINE_DATA

  950.       IGNORE_OPTIM_EMBEDDED_HINTS

  951.       OPTIMIZER_FEATURES_ENABLE ( \ '11.2.0.3\' )

  952.       DB_VERSION ( \ '11.2.0.3\' )

  953.       ALL_ROWS

  954.       OUTLINE_LEAF ( @ \ "SEL$5DA710D3\" )

  955.       UNNEST ( @ \ "SEL$2\" )

  956.       OUTLINE ( @ \ "SEL$1\" )

  957.       OUTLINE ( @ \ "SEL$2\" )

  958.       INDEX ( @ \ "SEL$5DA710D3\" \ "DEPT\" @ \ "SEL$1\" ( \ "DEPT\" . \ "DEPTNO\" ) )

  959.       FULL ( @ \ "SEL$5DA710D3\" \ "EMP\" @ \ "SEL$2\" )

  960.       LEADING ( @ \ "SEL$5DA710D3\" \ "DEPT\" @ \ "SEL$1\" \ "EMP\" @ \ "SEL$2\" )

  961.       USE_MERGE ( @ \ "SEL$5DA710D3\" \ "EMP\" @ \ "SEL$2\" )

  962.     END_OUTLINE_DATA

  963.    * /


  1. JF  -  join factorization:join 共同的項提取出來,沒必要的項刪掉。

  2. merge join 就是將兩個結果集排序,主要成本排序。

  3. semi join 半連結,跟exist演算法一樣。當做merge但一個結果集存在另一個結果集,我們就把這個值提出來。如果有就提取,沒有就不要。


這就是semi和inner join的區別,如果是inner join 那麼挑選出來的是所有的(3,3,4,5,5,6), 邏輯上是不一樣的,semi是個邏輯概念。這也是為什麼semi join 半連結比inner join、outer join快的原因。
anti join正好是反過來的

使用in和exists的等價查詢
相關引數
_unnest_subquery  關這些引數一般都是測試中
_optimizer_unnest_all_subqueries
_optimizer_squ_bottomup

相關hints
NO_QUERY_TRANSFORMATION   hints的作用就是不解套
unnest
no_unnest
push_subq no_push_subq
qb_name

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

相關文章