Visualizing SQL Pattern Matching (MATCH_RECOGNIZE) - A Beginner's Guide

  Рет қаралды 5,200

Oracle Developers

Oracle Developers

Күн бұрын

Пікірлер: 10
@santhoshreddykesavareddy1078
@santhoshreddykesavareddy1078 Жыл бұрын
Wow! The first 25 minutes you killed it with the explanation for the beginners and the rest rocks. But funny thing is I'm here for Snowflake but Oracle and Snowflake both has same syntax ( almost). Thank you so much
@6255445
@6255445 10 ай бұрын
To create / load the data mentioned in the video. create table run (run_date date, time_in_s number, distance_in_km number); insert into run values ('01-MAR-2023',310,1); insert into run values ('02-MAR-2023',1700,5); insert into run values ('03-MAR-2023',319,1); insert into run values ('06-MAR-2023',1572,5); insert into run values ('07-MAR-2023',280,1); insert into run values ('10-MAR-2023',287,1); insert into run values ('11-MAR-2023',242,1); insert into run values ('13-MAR-2023',1525,5); commit; -- 3 or more 1 km runs. select * from run match_recognize ( order by run_date all rows per match pattern (one_km{3,}) define one_km as distance_in_km = 1 ); -- 1 km run followed by a 5 km run. select * from run match_recognize ( order by run_date all rows per match pattern (one_km five_km) define one_km as distance_in_km = 1, five_km as distance_in_km = 5 ); -- With the additional columns. select * from run match_recognize ( order by run_date measures classifier () as var, match_number() as grp, final count(*) as num all rows per match pattern (one_km five_km) define one_km as distance_in_km = 1, five_km as distance_in_km = 5 );
@mustafakalayciDBA
@mustafakalayciDBA 2 жыл бұрын
Hi Chris, at time 17:06 that you put different conditions side by side, on the second example, NUM column is listed as 1 for "order by run_date ... pattern(one_km+)" but it must be 3 for rows 7,10,11 of march since three rows are consecutive and they matches to pattern "one_km+".
@TheMagicofSQL
@TheMagicofSQL 2 жыл бұрын
Ooops yes, good spot!
@mustafakalayciDBA
@mustafakalayciDBA 2 жыл бұрын
Hi again Chris, at time 43:25, at side by side comparison slide, second and third column output seems incorrect to me. "after match skip to next row" will start next pattern search at "next row of the previous matches first row" so, on second example, in the output after last row (13th of march) there should be a new matched rows group that start with row 10th of march. likewise on the third example (one_km five_km one_km pattern) there should be a second group starting with 3th of march because skip to next row will start search from the row of 2th of march. Am I wrong? outputs in the slides are look like an example of "after match skip past last row".
@TheMagicofSQL
@TheMagicofSQL 2 жыл бұрын
I'm unsure what you're saying. AFTER MATCH SKIP TO NEXT ROW goes to the next row NOT in a group. So never double counts rows. In the third example, it continues from the fourth row (6th March), not the second.
@mustafakalayciDBA
@mustafakalayciDBA 2 жыл бұрын
@@TheMagicofSQL Hi Chris, for the "after match skip to next row" doc says: "Resume pattern matching at the row after the first row of the current match.". the second example on the slide, all groups are correct but after the last group, there should be two more groups. one start from 10th of march and ends with 13th and the other start with 11th of march and end with 13th again. "one_km+ five_km" pattern matches 7 to 13th of march and also 10th to 13th and 11 to 13th. here is the sample: create table tmp (run_Date date, time_in_s number, distance_in_km number); insert into tmp values (trunc(sysdate, 'MONTH'), 310, 1); insert into tmp values (trunc(sysdate, 'MONTH')+1, 1700, 5); insert into tmp values (trunc(sysdate, 'MONTH')+2, 319, 1); insert into tmp values (trunc(sysdate, 'MONTH')+5, 1572, 5); insert into tmp values (trunc(sysdate, 'MONTH')+6, 280, 1); insert into tmp values (trunc(sysdate, 'MONTH')+9, 287, 1); insert into tmp values (trunc(sysdate, 'MONTH')+10, 242, 1); insert into tmp values (trunc(sysdate, 'MONTH')+12, 1535, 5); commit; select * from tmp match_recognize( order by run_Date measures classifier() as cls, match_number() as grp, final count(*) as num all rows per match after match skip to next row pattern(one_km+ five_km ) Define one_km as distance_in_km =1, five_km as distance_in_km =5 );
@TheMagicofSQL
@TheMagicofSQL 2 жыл бұрын
@@mustafakalayciDBA Ack, you're right! I mislabeled these - I intended the default behaviour AFTER MATCH SKIP PAST LAST ROW
@baraclude
@baraclude 2 жыл бұрын
my brain hurts
@TaranovskiAlex
@TaranovskiAlex 2 жыл бұрын
The quality of the audio is abysmal - like I'm at the conference call by phone in the 90s in the middle of nowhere... Oracle - multibillion dollar company - gets its billions by saving 50-100-200$ for a decent microphone? Any homegrown streamer has audio quality 10 times better than that nowadays...
In-Memory Hybrid Scans
51:54
Oracle Developers
Рет қаралды 391
Explaining Explain Plans
59:59
Oracle Developers
Рет қаралды 42 М.
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 4,1 МЛН
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 27 МЛН
Правильный подход к детям
00:18
Beatrise
Рет қаралды 10 МЛН
Pattern Matching + SQL Macros = Pure SQL Awesomeness!
58:04
Oracle Developers
Рет қаралды 11 М.
How to Use SQL Plan Baselines and SQL Profiles
55:14
Oracle Developers
Рет қаралды 14 М.
Splitting rows into buckets with SQL
49:40
Oracle Developers
Рет қаралды 6 М.
The five-step guide to SQL tuning | CloudWorld 2022
25:59
Oracle
Рет қаралды 22 М.
Top PL/SQL Tips In Just One Hour
1:00:53
Practically Perfect PL/SQL with Steven Feuerstein
Рет қаралды 53 М.
SQL hierarchies using CONNECT BY and recursive WITH
1:00:00
Oracle Developers
Рет қаралды 11 М.
Testing with utPLSQL
1:11:59
Oracle Developers
Рет қаралды 8 М.
Microservices with Databases can be challenging...
20:52
Software Developer Diaries
Рет қаралды 109 М.
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 4,1 МЛН