Skip to content

Instantly share code, notes, and snippets.

@xtender
Created June 7, 2015 19:06
Show Gist options
  • Select an option

  • Save xtender/2165c1d46fa95dc243d7 to your computer and use it in GitHub Desktop.

Select an option

Save xtender/2165c1d46fa95dc243d7 to your computer and use it in GitHub Desktop.
Modified solution by Randolf Geist
with v as(
select /*+ inline */ * from (
select /*+ index(li) */
rowid rid
from z_line_items li
where li.item_id = 42
union all
select rowid rid
from z_line_items li
where 1 = 2
)
)
select *
From (
select /*+ leading(v li o) use_nl(li o) parallel(v 8) */
li.*, o.*
from v
, z_line_items li
, z_orders o
where li.rowid = v.rid
and o.id = li.order_id
and o.order_type != 0
)
where rownum > 1;
-----------------------------------------------------------------------------------------------------------------------------------------
RTSM_SQL_ID
-------------
b4wn12sz3ggtc
-----------------------------------------------------------------------------------------------------------------------------------------
SQL Monitoring Report
Global Information
------------------------------
Status : DONE (ALL ROWS)
Instance ID : 1
Session : XTENDER (205:6177)
SQL ID : b4wn12sz3ggtc
SQL Execution ID : 16777216
Execution Started : 06/07/2015 22:04:05
First Refresh Time : 06/07/2015 22:04:06
Last Refresh Time : 06/07/2015 22:04:06
Duration : 1s
Module/Action : SQL*Plus/-
Service : baikal
Program : sqlplus.exe
Fetch Calls : 1
Global Stats
===============================================================
| Elapsed | Cpu | Concurrency | Other | Fetch | Buffer |
| Time(s) | Time(s) | Waits(s) | Waits(s) | Calls | Gets |
===============================================================
| 3.43 | 1.51 | 0.12 | 1.79 | 1 | 875K |
===============================================================
Parallel Execution Details (DOP=8 , Servers Allocated=8)
========================================================================================================
| Name | Type | Server# | Elapsed | Cpu | Concurrency | Other | Buffer | Wait Events |
| | | | Time(s) | Time(s) | Waits(s) | Waits(s) | Gets | (sample #) |
========================================================================================================
| PX Coordinator | QC | | 0.38 | 0.14 | 0.12 | 0.12 | 1033 | |
| p016 | Set 1 | 1 | 0.39 | 0.20 | | 0.19 | 109K | |
| p017 | Set 1 | 2 | 0.43 | | | 0.43 | 109K | |
| p018 | Set 1 | 3 | 0.35 | | | 0.35 | 109K | |
| p019 | Set 1 | 4 | 0.37 | 0.20 | | 0.17 | 109K | |
| p020 | Set 1 | 5 | 0.41 | 0.25 | | 0.16 | 109K | |
| p021 | Set 1 | 6 | 0.34 | 0.27 | | 0.07 | 109K | |
| p022 | Set 1 | 7 | 0.37 | 0.22 | | 0.15 | 109K | |
| p023 | Set 1 | 8 | 0.39 | 0.23 | | 0.16 | 109K | |
========================================================================================================
SQL Plan Monitoring Details (Plan Hash Value=4221710551)
===================================================================================================================================================================
| Id | Operation | Name | Rows | Cost | Time | Start | Execs | Rows | Mem | Activity | Activity Detail |
| | | | (Estim) | | Active(s) | Active | | (Actual) | (Max) | (%) | (# samples) |
===================================================================================================================================================================
| 0 | SELECT STATEMENT | | | | | | 1 | | | | |
| 1 | COUNT | | | | | | 1 | | | | |
| 2 | FILTER | | | | 1 | +1 | 1 | 0 | | | |
| 3 | PX COORDINATOR | | | | 1 | +1 | 9 | 361K | | | |
| 4 | PX SEND QC (RANDOM) | :TQ10001 | 358K | 110K | 1 | +1 | 8 | 361K | | | |
| 5 | NESTED LOOPS | | 358K | 110K | 1 | +1 | 8 | 361K | | | |
| 6 | NESTED LOOPS | | 394K | 110K | 1 | +1 | 8 | 396K | | | |
| 7 | NESTED LOOPS | | 394K | 55582 | 1 | +1 | 8 | 396K | | | |
| 8 | VIEW | | 394K | 889 | 1 | +1 | 8 | 396K | | | |
| 9 | UNION-ALL | | | | 1 | +1 | 8 | 396K | | | |
| 10 | BUFFER SORT | | | | 1 | +1 | 8 | 396K | 16M | | |
| 11 | PX RECEIVE | | | | 1 | +1 | 8 | 396K | | | |
| 12 | PX SEND ROUND-ROBIN | :TQ10000 | | | 1 | +1 | 1 | 396K | | | |
| 13 | INDEX RANGE SCAN | ITEM_ID__Z_LINE_ITEMS | 394K | 889 | 1 | +1 | 1 | 396K | | | |
| 14 | FILTER | | | | | | 8 | | | | |
| 15 | PX BLOCK ITERATOR | | 4M | 423 | | | | | | | |
| 16 | TABLE ACCESS FULL | Z_LINE_ITEMS | 4M | 423 | | | | | | | |
| 17 | TABLE ACCESS BY USER ROWID | Z_LINE_ITEMS | 1 | 1 | 1 | +1 | 396K | 396K | | | |
| 18 | INDEX UNIQUE SCAN | ID__Z_ORDERS | 1 | | 1 | +1 | 396K | 396K | | | |
| 19 | TABLE ACCESS BY INDEX ROWID | Z_ORDERS | 1 | | 1 | +1 | 396K | 361K | | | |
===================================================================================================================================================================
@vlsi

vlsi commented Jun 7, 2015

Copy link
Copy Markdown

This works even without with

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment