SQL_ID 5mjc0mzb8mwg0, child number 0 |
------------------------------------- |
with ranges_unpivot as ( /*Transform from_ ... to_... to the |
event-like structure*/ select id , val , val_type from |
ranges_table unpivot( val for val_type in (from_num as |
'01_START', to_num as '03_END') ) union all /*Append the rest |
of the data to the event stream*/ select null, id, /* |
This should be ordered between START mark and END mark to |
process edge cases correctly */ '02_val' from other_table |
where id <= (select max(to_num) from ranges_table) ) select max(count_) |
from ( select /*+parallel(4) gather_plan_statistics*/ * from |
ranges_unpivot match_recognize ( order by val asc, val_type asc |
measures start_.id as range_id, count(values_.val) as count_ |
pattern (start_ values_* end_) define start_ as val_type = |
'01_START', values_ as val_type = '02_val', end_ as val_type = |
'03_END' ) ) |
|
Plan hash value: 3946352968 |
|
--------------------------------------------------------------------------------------------------------------------------------------- |
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | Reads | OMem | 1Mem | Used-Mem | |
--------------------------------------------------------------------------------------------------------------------------------------- |
| 0 | SELECT STATEMENT | | 1 | | 1 |00:00:00.27 | 4431 | 4424 | | | | |
| 1 | SORT AGGREGATE | | 1 | 1 | 1 |00:00:00.27 | 4431 | 4424 | | | | |
| 2 | VIEW | | 1 | 50198 | 99 |00:00:00.27 | 4431 | 4424 | | | | |
| 3 | MATCH RECOGNIZE SORT | | 1 | 50198 | 99 |00:00:00.27 | 4431 | 4424 | 6573K| 1032K| 5842K (0)| |
| 4 | VIEW | | 1 | 50198 | 200K|00:00:00.14 | 4431 | 4424 | | | | |
| 5 | UNION-ALL | | 1 | | 200K|00:00:00.05 | 4431 | 4424 | | | | |
|* 6 | VIEW | | 1 | 198 | 198 |00:00:00.01 | 2 | 0 | | | | |
| 7 | UNPIVOT | | 1 | | 198 |00:00:00.01 | 2 | 0 | | | | |
| 8 | TABLE ACCESS FULL| RANGES_TABLE | 1 | 99 | 99 |00:00:00.01 | 2 | 0 | | | | |
|* 9 | TABLE ACCESS FULL | OTHER_TABLE | 1 | 50000 | 199K|00:00:00.02 | 4429 | 4424 | | | | |
| 10 | SORT AGGREGATE | | 1 | 1 | 1 |00:00:00.01 | 2 | 0 | | | | |
| 11 | TABLE ACCESS FULL| RANGES_TABLE | 1 | 99 | 99 |00:00:00.01 | 2 | 0 | | | | |
--------------------------------------------------------------------------------------------------------------------------------------- |
|
Predicate Information (identified by operation id): |
--------------------------------------------------- |
|
6 - filter("unpivot_view_010"."VAL" IS NOT NULL) |
9 - filter("ID"<=) |
|