SlideShare a Scribd company logo
BASEL BERN BRUGG DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. GENF
HAMBURG KOPENHAGEN LAUSANNE MÜNCHEN STUTTGART WIEN ZÜRICH
12c SQL Pattern Matching –
wann werde ich das benutzen?
Andrej Pashchenko
Senior Consultant
Trivadis GmbH
Unser Unternehmen.
12c SQL Pattern Matching – wann werde ich das benutzen?2 19.11.2015
Trivadis ist führend bei der IT-Beratung, der Systemintegration, dem Solution
Engineering und der Erbringung von IT-Services mit Fokussierung auf -
und -Technologien in der Schweiz, Deutschland, Österreich und
Dänemark. Trivadis erbringt ihre Leistungen aus den strategischen Geschäftsfeldern:
Trivadis Services übernimmt den korrespondierenden Betrieb Ihrer IT Systeme.
B E T R I E B
KOPENHAGEN
MÜNCHEN
LAUSANNE
BERN
ZÜRICH
BRUGG
GENF
HAMBURG
DÜSSELDORF
FRANKFURT
STUTTGART
FREIBURG
BASEL
WIEN
Mit über 600 IT- und Fachexperten bei Ihnen vor Ort.
12c SQL Pattern Matching – wann werde ich das benutzen?3 19.11.2015
14 Trivadis Niederlassungen mit
über 600 Mitarbeitenden.
Über 200 Service Level Agreements.
Mehr als 4'000 Trainingsteilnehmer.
Forschungs- und Entwicklungsbudget:
CHF 5.0 Mio.
Finanziell unabhängig und
nachhaltig profitabel.
Erfahrung aus mehr als 1'900 Projekten
pro Jahr bei über 800 Kunden.
Über mich
12c SQL Pattern Matching – wann werde ich das benutzen?4 19.11.2015
Senior Consultant bei der Trivadis GmbH, Düsseldorf
Schwerpunkt Oracle
– Application Development
– Application Performance
– Data Warehousing
22 Jahre IT-Erfahrung, davon 16 Jahre mit Oracle DB
Kurs-Referent „Oracle 12c New Features für Entwickler“
und „Beyond SQL and PL/SQL“
Blog: http://blog.sqlora.com
Agenda
12c SQL Pattern Matching – wann werde ich das benutzen?5 19.11.2015
1. Introduction
2. Find consecutive ranges and gaps
3. Trouble Ticket roundtrip
4. Grouping on fuzzy criteria
5. Merge temporal intervals
12c SQL Pattern Matching – wann werde ich das benutzen?6 19.11.2015
Introduction
Introduction
12c SQL Pattern Matching – wann werde ich das benutzen?7 19.11.2015
Analytic
functions
Analytic
functions
enhancements
SQL Model
Clause
LISTAGG
NTH_VALUE
PIVOT/UNPIVOT
clause
Pattern
Matching
Top-N
Introduction
Oracle 12c database supports SQL Pattern Matching with the new
clause - MATCH_RECOGNIZE
pattern matching in a sequences of rows
nothing to do with string patterns (PL/SQL REGEXP_...
functions)
it‘s a clause, not a function
after the table name in FROM clause
patterns are expressed with regular expression syntax over
pattern variables
pattern variables are defined as SQL expressions
19.11.2015 12c SQL Pattern Matching – wann werde ich das benutzen?8
Introduction
19.11.2015 12c SQL Pattern Matching – wann werde ich das benutzen?9
MATCH_RECOGNIZE
( [ PARTITION BY <cols> ]
[ ORDER BY <cols> ]
[ MEASURES <cols> ]
[ ONE ROW PER MATCH | ALL ROWS PER MATCH ]
[ SKIP_TO <option> ]
PATTERN ( <row pattern> )
[ SUBSET <subset list> ]
DEFINE <definition list> )
Introduction
Example: Find Mappings in the ETL logging table, which were
increasingly faster over a period of four days. Output: start and end dates
of the period, elapsed time at the beginning and the end of the period,
average elapsed time.
19.11.2015 12c SQL Pattern Matching – wann werde ich das benutzen?10
Introduction
SELECT etl_date, mapping_name, elapsed
FROM dwh_etl_runs;
...
04-NOV-14 MAP_STG_S_ORDER_ITEM +000000 00:14:54.42738
05-NOV-14 MAP_STG_S_ORDER +000000 00:10:13.44989
05-NOV-14 MAP_STG_S_ORDER_ITEM +000000 00:15:06.24587
05-NOV-14 MAP_STG_S_ASSET +000000 00:14:15.22855
06-NOV-14 MAP_STG_S_ASSET +000000 00:14:00.49513
06-NOV-14 MAP_STG_S_ORDER +000000 00:11:05.07337
06-NOV-14 MAP_STG_S_ORDER_ITEM +000000 00:10:12.67410
07-NOV-14 MAP_STG_S_ORDER_ITEM +000000 00:19:29.64314
07-NOV-14 MAP_STG_S_ORDER +000000 00:14:59.80953
07-NOV-14 MAP_STG_S_ASSET +000000 00:13:33.80789
08-NOV-14 MAP_STG_S_ASSET +000000 00:10:14.65652
08-NOV-14 MAP_STG_S_ORDER +000000 00:13:30.77744
08-NOV-14 MAP_STG_S_ORDER_ITEM +000000 00:17:15.11789
...
19.11.2015 12c SQL Pattern Matching – wann werde ich das benutzen?11
Introduction
12c SQL Pattern Matching – wann werde ich das benutzen?12
SELECT *
FROM dwh_etl_runs MATCH_RECOGNIZE (
PARTITION BY mapping_name
ORDER BY etl_date
MEASURES FIRST (etl_date) AS start_date
, LAST (etl_date) AS end_date
, FIRST (elapsed) AS first_elapsed
, LAST (elapsed) AS last_elapsed
, AVG(elapsed) AS avg_elapsed
PATTERN (STRT DOWN{3})
DEFINE DOWN AS elapsed < PREV(elapsed) )
As for analytic functions:
partition and order
Define measures, which are
accessible in the main query
Define search pattern with
regular expression over boolean
pattern variables
Define pattern variables
Navigation operators:
▪ PREV, NEXT – physical offset
▪ FIRST, LAST – logical offset
19.11.2015
Introduction
12c SQL Pattern Matching – wann werde ich das benutzen?13
PATTERN: Subset of Perl syntax for regular expressions
– * — 0 or more iterations
– + — 1 or more iterations
– ? — 0 or 1 iterations
– {n} — n iterations (n > 0)
– {n,} — n or more iterations (n >= 0)
– {n,m} — between n and m (inclusive) iterations (0 <= n <= m, 0 < m)
– {,m} — between 0 and m (inclusive) iterations (m > 0)
– ( ) – Grouping
– | – Alternation
– {- … -} – Exclusion
– ^ - before the first row in the Partition
– $ - after the last row in the partition
– ? – “reluctant” vs. “greedy”
– ….
19.11.2015
Introduction
12c SQL Pattern Matching – wann werde ich das benutzen?14
Patterns are everywhere
Financial
Telcos
Retail Traffic
Automotive
Transport /
Logistics
Fraud Detection
Quality of Service
Trouble Ticketing
Price Trends
Buying Patterns
Stock Market Money
Laundering
Sensor Data
Network Activity
Advertising
Campaigns
Sessionization
Frequent Flyer
Programms
Process Chain
CRM
19.11.2015
Introduction
12c SQL Pattern Matching – wann werde ich das benutzen?15
SQL had no efficient way to handle such questions
pre 12c solutions
self-joins, subqueries (NOT) IN, (NOT) EXISTS
switch to PL/SQL - „Do it yourself“, often multiple SQL queries
transfer some logic to pipelined functions and integrate them in
the main query
analytic (window) functions
– ORA-30483: window functions are not allowed here
– not possible to use in WHERE clause
– not possible to nest them
– unable to access the output of analytic functions in other rows
– often leads to nesting queries, self-joins, etc.
19.11.2015
Agenda
12c SQL Pattern Matching – wann werde ich das benutzen?16 19.11.2015
1. Introduction
2. Find consecutive ranges and gaps
3. Trouble Ticket roundtrip
4. Grouping on fuzzy criteria
5. Merge temporal intervals
12c SQL Pattern Matching – wann werde ich das benutzen?17 19.11.2015
Find consecutive ranges and gaps
Find Consecutive Ranges / Gaps
12c SQL Pattern Matching – wann werde ich das benutzen?18
SLA, QoS: find the longest period without outage
Table T_GAPS
Find consecutive ranges in the values of column ID
Output: Start- and End-ID of consecutive range
ID
1
2
3
5
6
10
11
12
14
20
21
…
mr_consecutive.sql
Start of Range End of Range
1 3
5 6
10 12
19.11.2015
Find Consecutive Ranges / Gaps
12c SQL Pattern Matching – wann werde ich das benutzen?19
Pre 12c solution using analytic functionsID
1
2
3
5
6
10
11
12
14
20
21
…
WITH groups_marked AS (
SELECT id
, CASE
WHEN id != LAG(id,1,id) OVER(ORDER BY id) + 1 THEN 1
ELSE 0
END new_grp
FROM t_gaps)
, sum_grp AS (
SELECT id, SUM(new_grp) OVER(ORDER BY id) grp_sum
FROM groups_marked )
SELECT MIN(id) start_of_range
, MAX(id) end_of_range
FROM sum_grp
GROUP BY grp_sum
ORDER BY grp_sum;
mr_consecutive.sql
19.11.2015
Find Consecutive Ranges / Gaps
12c SQL Pattern Matching – wann werde ich das benutzen?20
„Tabibitosan“- method*
* - https://community.oracle.com/message/3991177#3991177
ID
1
2
3
5
6
10
11
12
14
20
21
…
SELECT MIN(id) start_of_range
, MAX(id) end_of_range
FROM (SELECT id
, id - ROW_NUMBER() OVER(ORDER BY id) distance
FROM t_gaps)
GROUP BY distance
ORDER BY distance;
mr_consecutive.sql
19.11.2015
Find Consecutive Ranges / Gaps
12c SQL Pattern Matching – wann werde ich das benutzen?21
12c solution with MATCH_RECOGINZEID
1
2
3
5
6
10
11
12
14
20
21
…
SELECT *
FROM t_gaps MATCH_RECOGNIZE (
ORDER BY id
MEASURES FIRST(id) start_of_range
, LAST(id) end_of_range
, COUNT(*) cnt
ONE ROW PER MATCH
PATTERN (strt cont*)
DEFINE cont AS id = PREV(id)+1
);
mr_consecutive.sql
19.11.2015
Find Consecutive Ranges / Gaps
12c SQL Pattern Matching – wann werde ich das benutzen?22
Table T_GAPS, numeric column ID with gaps
Find the gaps in the values of column ID
Output: start- and end-ID of the gap
ID
1
2
3
5
6
10
11
12
14
20
21
…
mr_gaps.sql
Start of Gap End of Gap
4 4
7 9
13 13
15 19
19.11.2015
Find Consecutive Ranges / Gaps
12c SQL Pattern Matching – wann werde ich das benutzen?23
Solution with analytic functions
„Tabibitosan“-method*
* - https://community.oracle.com/message/3991177#3991177
ID
1
2
3
5
6
10
11
12
14
20
21
…
mr_gaps.sql
SELECT start_of_gap, end_of_gap
FROM ( SELECT id + 1 start_of_gap
, LEAD(id) OVER(ORDER BY id) - 1 end_of_gap
, CASE
WHEN id + 1 != LEAD(id) OVER(ORDER BY id) THEN 1
ELSE 0
END is_gap
FROM t_gaps)
WHERE is_gap = 1;
SELECT MAX(id) + 1 start_of_gap
, LEAD(MIN(id)) OVER (ORDER BY distance) -1 end_of_gap
FROM (SELECT id
, id - ROW_NUMBER() OVER(ORDER BY id) distance
FROM t_gaps)
GROUP BY distance;
19.11.2015
Find Consecutive Ranges / Gaps
12c SQL Pattern Matching – wann werde ich das benutzen?24
12c solution with MATCH_RECOGINZEID
1
2
3
5
6
10
11
12
14
20
21
…
mr_gaps.sql
SELECT *
FROM t_gaps MATCH_RECOGNIZE (
ORDER BY id
MEASURES PREV(gap.id)+1 start_of_gap
, gap.id - 1 end_of_gap
ONE ROW PER MATCH
PATTERN (strt gap+)
DEFINE gap AS id != PREV(id)+1
);
19.11.2015
Agenda
12c SQL Pattern Matching – wann werde ich das benutzen?25 19.11.2015
1. Introduction
2. Find consecutive ranges and gaps
3. Trouble Ticket roundtrip
4. Grouping on fuzzy criteria
5. Merge temporal intervals
12c SQL Pattern Matching – wann werde ich das benutzen?26 19.11.2015
Trouble Ticket roundtrip
Trouble Ticket Roundtrip
12c SQL Pattern Matching – wann werde ich das benutzen?27
SCOTT
ADAMS
KING
ID Assignee Datum
1 SCOTT 01.02.2015
1 SCOTT 02.02.2015
1 ADAMS 03.02.2015
1 SCOTT 04.02.2015
2 ADAMS 01.02.2015
2 ADAMS 02.02.2015
2 SCOTT 03.02.2015
3 KING 01.02.2015
3 ADAMS 02.02.2015
3 ADAMS 03.02.2015
3 KING 04.02.2015
3 ADAMS 05.02.2015
4 KING 01.02.2015
4 ADAMS 02.02.2015
4 SCOTT 03.02.2015
4 KING 05.02.2015
▪ Find the tickets, which went
again to the same assignee
19.11.2015
Trouble Ticket Roundtrip
12c SQL Pattern Matching – wann werde ich das benutzen?28
Pre12c solution using self-joins
mr_trouble_ticket.sql
SELECT DISTINCT t1.ticket_id
, t1.assignee AS first_assignee
, t3.change_date AS last_change
FROM trouble_ticket t1
, trouble_ticket t2
, trouble_ticket t3
WHERE t1.ticket_id = t2.ticket_id
AND t1.assignee != t2.assignee
AND t2.change_date > t1.change_date
AND t3.assignee = t1.assignee
AND t3.ticket_id = t1.ticket_id
AND t3.change_date > t2.change_date
ORDER BY ticket_id
19.11.2015
Trouble Ticket Roundtrip
12c SQL Pattern Matching – wann werde ich das benutzen?29
12c solution using MATCH_RECOGINZE clause
New:
– Row Pattern Skip To:
where to start over after
match?
– match overlaping patterns
mr_trouble_ticket.sql
SELECT *
FROM trouble_ticket
MATCH_RECOGNIZE(
PARTITION BY ticket_id
ORDER BY change_date
MEASURES strt.assignee as first_assignee
, LAST(same.change_date) as letzte_bearbeitung
AFTER MATCH SKIP TO FIRST another
PATTERN (strt another+ same+)
DEFINE same AS same.assignee = strt.assignee,
another AS another.assignee != strt.assignee
);
Where to start over after a
match is found?
19.11.2015
Agenda
12c SQL Pattern Matching – wann werde ich das benutzen?30 19.11.2015
1. Introduction
2. Find consecutive ranges and gaps
3. Trouble Ticket roundtrip
4. Grouping on fuzzy criteria
5. Merge temporal intervals
12c SQL Pattern Matching – wann werde ich das benutzen?31 19.11.2015
Grouping on fuzzy criteria
Grouping over fuzzy criteria
12c SQL Pattern Matching – wann werde ich das benutzen?32
„Sessionization“
– Group rows together where the gap between the timestamps is less
than defined
...
PATTERN (STRT SESS+)
DEFINE SESS AS SESS.ins_date – PREV(SESS.ins_date)<= 10/24/60
– Group rows together that are within a defined interval relatively to the
first row, otherwise start next group
https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID
:13946369553642#3478381500346951056
...
PATTERN (A+)
DEFINE A AS ins_date < FIRST(ins_date) + 6/24
Group over running totals
– Split the data into the groups of defined capacity
19.11.2015
Grouping over fuzzy criteria
12c SQL Pattern Matching – wann werde ich das benutzen?33
Example-Schema SH (Sales History)
Task: split the data into the group of fixed
capacity
▪ Fit all customers ordered by age into
groups providing that total sales in every
group < 200 000$
19.11.2015
Grouping over fuzzy criteria
12c SQL Pattern Matching – wann werde ich das benutzen?34
12c solution with MATCH_RECOGINZE clause
mr_group_running_total.sql
WITH q AS (SELECT c.cust_id, c.cust_year_of_birth
, SUM(s.amount_sold) cust_amount_sold
FROM customers c JOIN sales s ON s.cust_id = c.cust_id
GROUP BY c.cust_id, c.cust_year_of_birth
)
SELECT *
FROM q
MATCH_RECOGNIZE(
ORDER BY cust_year_of_birth
MEASURES MATCH_NUMBER() gruppe
, SUM(cust_amount_sold) running_sum
, FINAL SUM(cust_amount_sold) final_sum
ALL ROWS PER MATCH
PATTERN (gr*)
DEFINE gr AS SUM(cust_amount_sold)<=200000
);
We need all matches
Aggregate function in
pattern variable‘s condition
function returns the macth
number
Aggregates in MEASURES:
Running vs. Final
19.11.2015
Agenda
12c SQL Pattern Matching – wann werde ich das benutzen?35 19.11.2015
1. Introduction
2. Find consecutive ranges and gaps
3. Trouble Ticket roundtrip
4. Grouping on fuzzy criteria
5. Merge temporal intervals
12c SQL Pattern Matching – wann werde ich das benutzen?36 19.11.2015
Merge temporal intervals
Merge temporal intervals
12c SQL Pattern Matching – wann werde ich das benutzen?37
Temporal version of SCOTT-Schema: the data in EMP, DEPT and
JOB have temporal validity (VALID_FROM - VALID_TO)
19.11.2015
Merge temporal intervals
12c SQL Pattern Matching – wann werde ich das benutzen?38
Task: Query the data for one employee joining four tables with
respect of temporal validity:
19.11.2015
Merge temporal intervals
12c SQL Pattern Matching – wann werde ich das benutzen?39
WITH joined AS (
SELECT e.empno,
g.valid_from,
LEAST( e.valid_to, d.valid_to, j.valid_to,
NVL(m.valid_to, e.valid_to),
LEAD(g.valid_from - 1, 1, e.valid_to) OVER(
PARTITION BY e.empno ORDER BY g.valid_from )
) AS valid_to,
e.ename, j.job, e.mgr, m.ename AS mgr_ename, e.hiredate,
e.sal, e.comm, e.deptno, d.dname
FROM empv e
INNER JOIN (SELECT valid_from FROM empv
UNION
SELECT valid_from FROM deptv
UNION
SELECT valid_from FROM jobv
UNION
SELECT valid_to + 1 FROM empv
WHERE valid_to != DATE '9999-12-31'
UNION
SELECT valid_to + 1 FROM deptv
WHERE valid_to != DATE '9999-12-31'
UNION
SELECT valid_to + 1 FROM jobv
WHERE valid_to != DATE '9999-12-31') g
ON g.valid_from BETWEEN e.valid_from AND e.valid_to
INNER JOIN deptv d
ON d.deptno = e.deptno AND g.valid_from BETWEEN d.valid_from AND d.valid_to
INNER JOIN jobv j
ON j.jobno = e.jobno AND g.valid_from BETWEEN j.valid_from AND j.valid_to
LEFT JOIN empv m
ON m.empno = e.mgr AND g.valid_from BETWEEN m.valid_from AND m.valid_to )
...
Quelle: Philipp Salvisberg:
http://www.salvis.com/blog/2012/12/28/joining-temporal-intervals-part-2/
19.11.2015
Merge temporal intervals
12c SQL Pattern Matching – wann werde ich das benutzen?40
...
SELECT empno, valid_from, valid_to, ename, job, mgr,
mgr_ename, hiredate, sal, comm, deptno, dname
FROM joined
MATCH_RECOGNIZE (
PARTITION BY empno, ename, job, mgr,
mgr_ename, hiredate, sal, comm,
deptno, dname
ORDER BY valid_from
MEASURES FIRST(valid_from) valid_from,
LAST(valid_to) valid_to
PATTERN ( strt nxt* )
DEFINE nxt as valid_from = prev(valid_to) + 1
)
WHERE empno = 7788;
19.11.2015
Conclusion
12c SQL Pattern Matching – wann werde ich das benutzen?41
Very powerful feature
Significantly simplifies a lot of queries (self-joins, semi-, anti-joins, nested queries),
mostly with performance benefit
Since 2007 a proposal for ANSI-SQL
Requires thinking in patterns
Complicated syntax (at first sight )
But in many cases the code looks like the requirement in „plain English“
19.11.2015
Further information...
12c SQL Pattern Matching – wann werde ich das benutzen?42
Database Data Warehousing Guide - SQL for Pattern Matching -
http://docs.oracle.com/database/121/DWHSG/pattern.htm#DWHSG8956
Stewart Ashton‘s Blog - https://stewashton.wordpress.com
Oracle Whitepaper - Patterns everywhere - Find them Fast! -
http://www.oracle.com/ocom/groups/public/@otn/documents/webcontent/1965433.pdf
19.11.2015
12c SQL Pattern Matching – wann werde ich das benutzen?43 19.11.2015
Trivadis an der DOAG 2015
Ebene 3 - gleich neben der Rolltreppe
Wir freuen uns auf Ihren Besuch.
Denn mit Trivadis gewinnen Sie immer.

More Related Content

What's hot

Oracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsOracle Performance Tuning Fundamentals
Oracle Performance Tuning Fundamentals
Enkitec
 
How a Developer can Troubleshoot a SQL performing poorly on a Production DB
How a Developer can Troubleshoot a SQL performing poorly on a Production DBHow a Developer can Troubleshoot a SQL performing poorly on a Production DB
How a Developer can Troubleshoot a SQL performing poorly on a Production DB
Carlos Sierra
 
SQL Tuning 101
SQL Tuning 101SQL Tuning 101
SQL Tuning 101
Carlos Sierra
 
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
Carlos Sierra
 
Average Active Sessions - OaktableWorld 2013
Average Active Sessions - OaktableWorld 2013Average Active Sessions - OaktableWorld 2013
Average Active Sessions - OaktableWorld 2013
John Beresniewicz
 
Polymorphic Table Functions in SQL
Polymorphic Table Functions in SQLPolymorphic Table Functions in SQL
Polymorphic Table Functions in SQL
Chris Saxon
 
SQL Plan Directives explained
SQL Plan Directives explainedSQL Plan Directives explained
SQL Plan Directives explained
Mauro Pagano
 
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Aaron Shilo
 
Online index rebuild automation
Online index rebuild automationOnline index rebuild automation
Online index rebuild automation
Carlos Sierra
 
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
Your tuning arsenal: AWR, ADDM, ASH, Metrics and AdvisorsYour tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
John Kanagaraj
 
Performance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresPerformance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and Underscores
Jitendra Singh
 
Tanel Poder - Scripts and Tools short
Tanel Poder - Scripts and Tools shortTanel Poder - Scripts and Tools short
Tanel Poder - Scripts and Tools short
Tanel Poder
 
Oracle DB 19c: SQL Tuning Using SPM
Oracle DB 19c: SQL Tuning Using SPMOracle DB 19c: SQL Tuning Using SPM
Oracle DB 19c: SQL Tuning Using SPM
Arturo Aranda
 
Tanel Poder Oracle Scripts and Tools (2010)
Tanel Poder Oracle Scripts and Tools (2010)Tanel Poder Oracle Scripts and Tools (2010)
Tanel Poder Oracle Scripts and Tools (2010)
Tanel Poder
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.
Alexey Lesovsky
 
Oracle SQL Tuning for Day-to-Day Data Warehouse Support
Oracle SQL Tuning for Day-to-Day Data Warehouse SupportOracle SQL Tuning for Day-to-Day Data Warehouse Support
Oracle SQL Tuning for Day-to-Day Data Warehouse Support
nkarag
 
07 Using Oracle-Supported Package in Application Development
07 Using Oracle-Supported Package in Application Development07 Using Oracle-Supported Package in Application Development
07 Using Oracle-Supported Package in Application Development
rehaniltifat
 
Top 10 Mistakes When Migrating From Oracle to PostgreSQL
Top 10 Mistakes When Migrating From Oracle to PostgreSQLTop 10 Mistakes When Migrating From Oracle to PostgreSQL
Top 10 Mistakes When Migrating From Oracle to PostgreSQL
Jim Mlodgenski
 
PostgreSQL Performance Tuning
PostgreSQL Performance TuningPostgreSQL Performance Tuning
PostgreSQL Performance Tuningelliando dias
 
Oracle Golden Gate Interview Questions
Oracle Golden Gate Interview QuestionsOracle Golden Gate Interview Questions
Oracle Golden Gate Interview Questions
Arun Sharma
 

What's hot (20)

Oracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsOracle Performance Tuning Fundamentals
Oracle Performance Tuning Fundamentals
 
How a Developer can Troubleshoot a SQL performing poorly on a Production DB
How a Developer can Troubleshoot a SQL performing poorly on a Production DBHow a Developer can Troubleshoot a SQL performing poorly on a Production DB
How a Developer can Troubleshoot a SQL performing poorly on a Production DB
 
SQL Tuning 101
SQL Tuning 101SQL Tuning 101
SQL Tuning 101
 
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
 
Average Active Sessions - OaktableWorld 2013
Average Active Sessions - OaktableWorld 2013Average Active Sessions - OaktableWorld 2013
Average Active Sessions - OaktableWorld 2013
 
Polymorphic Table Functions in SQL
Polymorphic Table Functions in SQLPolymorphic Table Functions in SQL
Polymorphic Table Functions in SQL
 
SQL Plan Directives explained
SQL Plan Directives explainedSQL Plan Directives explained
SQL Plan Directives explained
 
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
 
Online index rebuild automation
Online index rebuild automationOnline index rebuild automation
Online index rebuild automation
 
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
Your tuning arsenal: AWR, ADDM, ASH, Metrics and AdvisorsYour tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
 
Performance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresPerformance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and Underscores
 
Tanel Poder - Scripts and Tools short
Tanel Poder - Scripts and Tools shortTanel Poder - Scripts and Tools short
Tanel Poder - Scripts and Tools short
 
Oracle DB 19c: SQL Tuning Using SPM
Oracle DB 19c: SQL Tuning Using SPMOracle DB 19c: SQL Tuning Using SPM
Oracle DB 19c: SQL Tuning Using SPM
 
Tanel Poder Oracle Scripts and Tools (2010)
Tanel Poder Oracle Scripts and Tools (2010)Tanel Poder Oracle Scripts and Tools (2010)
Tanel Poder Oracle Scripts and Tools (2010)
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.
 
Oracle SQL Tuning for Day-to-Day Data Warehouse Support
Oracle SQL Tuning for Day-to-Day Data Warehouse SupportOracle SQL Tuning for Day-to-Day Data Warehouse Support
Oracle SQL Tuning for Day-to-Day Data Warehouse Support
 
07 Using Oracle-Supported Package in Application Development
07 Using Oracle-Supported Package in Application Development07 Using Oracle-Supported Package in Application Development
07 Using Oracle-Supported Package in Application Development
 
Top 10 Mistakes When Migrating From Oracle to PostgreSQL
Top 10 Mistakes When Migrating From Oracle to PostgreSQLTop 10 Mistakes When Migrating From Oracle to PostgreSQL
Top 10 Mistakes When Migrating From Oracle to PostgreSQL
 
PostgreSQL Performance Tuning
PostgreSQL Performance TuningPostgreSQL Performance Tuning
PostgreSQL Performance Tuning
 
Oracle Golden Gate Interview Questions
Oracle Golden Gate Interview QuestionsOracle Golden Gate Interview Questions
Oracle Golden Gate Interview Questions
 

Similar to SQL Pattern Matching – should I start using it?

Analysing Performance of Algorithmic SQL and PLSQL.pptx
Analysing Performance of Algorithmic SQL and PLSQL.pptxAnalysing Performance of Algorithmic SQL and PLSQL.pptx
Analysing Performance of Algorithmic SQL and PLSQL.pptx
Brendan Furey
 
SQL Optimization With Trace Data And Dbms Xplan V6
SQL Optimization With Trace Data And Dbms Xplan V6SQL Optimization With Trace Data And Dbms Xplan V6
SQL Optimization With Trace Data And Dbms Xplan V6
Mahesh Vallampati
 
Dimensional performance benchmarking of SQL
Dimensional performance benchmarking of SQLDimensional performance benchmarking of SQL
Dimensional performance benchmarking of SQL
Brendan Furey
 
Database programming
Database programmingDatabase programming
Chapter15
Chapter15Chapter15
Chapter15
gourab87
 
Base sas interview questions
Base sas interview questionsBase sas interview questions
Base sas interview questionsDr P Deepak
 
Base sas interview questions
Base sas interview questionsBase sas interview questions
Base sas interview questions
Sunil0108
 
Apache Lens at Hadoop meetup
Apache Lens at Hadoop meetupApache Lens at Hadoop meetup
Apache Lens at Hadoop meetup
amarsri
 
Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?
Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?
Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?
Martin Loetzsch
 
Presentation interpreting execution plans for sql statements
Presentation    interpreting execution plans for sql statementsPresentation    interpreting execution plans for sql statements
Presentation interpreting execution plans for sql statements
xKinAnx
 
MIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresMIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome Measures
Steven Johnson
 
Indexes overview
Indexes overviewIndexes overview
Indexes overview
aioughydchapter
 
Spark ml streaming
Spark ml streamingSpark ml streaming
Spark ml streaming
Adam Doyle
 
Top 10 Oracle SQL tuning tips
Top 10 Oracle SQL tuning tipsTop 10 Oracle SQL tuning tips
Top 10 Oracle SQL tuning tips
Nirav Shah
 
Arrays and lists in sql server 2008
Arrays and lists in sql server 2008Arrays and lists in sql server 2008
Arrays and lists in sql server 2008
nxthuong
 
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
Tony jambu   (obscure) tools of the trade for tuning oracle sq lsTony jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
InSync Conference
 
TechEvent Introduction to GraphQL
TechEvent Introduction to GraphQLTechEvent Introduction to GraphQL
TechEvent Introduction to GraphQL
Trivadis
 
Cassandra20141113
Cassandra20141113Cassandra20141113
Cassandra20141113
Brian Enochson
 

Similar to SQL Pattern Matching – should I start using it? (20)

Analysing Performance of Algorithmic SQL and PLSQL.pptx
Analysing Performance of Algorithmic SQL and PLSQL.pptxAnalysing Performance of Algorithmic SQL and PLSQL.pptx
Analysing Performance of Algorithmic SQL and PLSQL.pptx
 
SQL Optimization With Trace Data And Dbms Xplan V6
SQL Optimization With Trace Data And Dbms Xplan V6SQL Optimization With Trace Data And Dbms Xplan V6
SQL Optimization With Trace Data And Dbms Xplan V6
 
Dimensional performance benchmarking of SQL
Dimensional performance benchmarking of SQLDimensional performance benchmarking of SQL
Dimensional performance benchmarking of SQL
 
Database programming
Database programmingDatabase programming
Database programming
 
Oct.22nd.Presentation.Final
Oct.22nd.Presentation.FinalOct.22nd.Presentation.Final
Oct.22nd.Presentation.Final
 
Chapter15
Chapter15Chapter15
Chapter15
 
NoSQL
NoSQLNoSQL
NoSQL
 
Base sas interview questions
Base sas interview questionsBase sas interview questions
Base sas interview questions
 
Base sas interview questions
Base sas interview questionsBase sas interview questions
Base sas interview questions
 
Apache Lens at Hadoop meetup
Apache Lens at Hadoop meetupApache Lens at Hadoop meetup
Apache Lens at Hadoop meetup
 
Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?
Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?
Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?
 
Presentation interpreting execution plans for sql statements
Presentation    interpreting execution plans for sql statementsPresentation    interpreting execution plans for sql statements
Presentation interpreting execution plans for sql statements
 
MIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresMIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome Measures
 
Indexes overview
Indexes overviewIndexes overview
Indexes overview
 
Spark ml streaming
Spark ml streamingSpark ml streaming
Spark ml streaming
 
Top 10 Oracle SQL tuning tips
Top 10 Oracle SQL tuning tipsTop 10 Oracle SQL tuning tips
Top 10 Oracle SQL tuning tips
 
Arrays and lists in sql server 2008
Arrays and lists in sql server 2008Arrays and lists in sql server 2008
Arrays and lists in sql server 2008
 
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
Tony jambu   (obscure) tools of the trade for tuning oracle sq lsTony jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
 
TechEvent Introduction to GraphQL
TechEvent Introduction to GraphQLTechEvent Introduction to GraphQL
TechEvent Introduction to GraphQL
 
Cassandra20141113
Cassandra20141113Cassandra20141113
Cassandra20141113
 

Recently uploaded

社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .
NABLAS株式会社
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
nscud
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
ewymefz
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
u86oixdj
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
axoqas
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
Oppotus
 
Empowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptxEmpowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptx
benishzehra469
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Subhajit Sahu
 
一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单
ewymefz
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
balafet
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
yhkoc
 
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
oz8q3jxlp
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
ewymefz
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
ArpitMalhotra16
 
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
mbawufebxi
 
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
vcaxypu
 
FP Growth Algorithm and its Applications
FP Growth Algorithm and its ApplicationsFP Growth Algorithm and its Applications
FP Growth Algorithm and its Applications
MaleehaSheikh2
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Subhajit Sahu
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
enxupq
 

Recently uploaded (20)

社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
 
Empowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptxEmpowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptx
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
 
一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
 
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
 
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
一比一原版(Bradford毕业证书)布拉德福德大学毕业证如何办理
 
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
 
FP Growth Algorithm and its Applications
FP Growth Algorithm and its ApplicationsFP Growth Algorithm and its Applications
FP Growth Algorithm and its Applications
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
 

SQL Pattern Matching – should I start using it?

  • 1. BASEL BERN BRUGG DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. GENF HAMBURG KOPENHAGEN LAUSANNE MÜNCHEN STUTTGART WIEN ZÜRICH 12c SQL Pattern Matching – wann werde ich das benutzen? Andrej Pashchenko Senior Consultant Trivadis GmbH
  • 2. Unser Unternehmen. 12c SQL Pattern Matching – wann werde ich das benutzen?2 19.11.2015 Trivadis ist führend bei der IT-Beratung, der Systemintegration, dem Solution Engineering und der Erbringung von IT-Services mit Fokussierung auf - und -Technologien in der Schweiz, Deutschland, Österreich und Dänemark. Trivadis erbringt ihre Leistungen aus den strategischen Geschäftsfeldern: Trivadis Services übernimmt den korrespondierenden Betrieb Ihrer IT Systeme. B E T R I E B
  • 3. KOPENHAGEN MÜNCHEN LAUSANNE BERN ZÜRICH BRUGG GENF HAMBURG DÜSSELDORF FRANKFURT STUTTGART FREIBURG BASEL WIEN Mit über 600 IT- und Fachexperten bei Ihnen vor Ort. 12c SQL Pattern Matching – wann werde ich das benutzen?3 19.11.2015 14 Trivadis Niederlassungen mit über 600 Mitarbeitenden. Über 200 Service Level Agreements. Mehr als 4'000 Trainingsteilnehmer. Forschungs- und Entwicklungsbudget: CHF 5.0 Mio. Finanziell unabhängig und nachhaltig profitabel. Erfahrung aus mehr als 1'900 Projekten pro Jahr bei über 800 Kunden.
  • 4. Über mich 12c SQL Pattern Matching – wann werde ich das benutzen?4 19.11.2015 Senior Consultant bei der Trivadis GmbH, Düsseldorf Schwerpunkt Oracle – Application Development – Application Performance – Data Warehousing 22 Jahre IT-Erfahrung, davon 16 Jahre mit Oracle DB Kurs-Referent „Oracle 12c New Features für Entwickler“ und „Beyond SQL and PL/SQL“ Blog: http://blog.sqlora.com
  • 5. Agenda 12c SQL Pattern Matching – wann werde ich das benutzen?5 19.11.2015 1. Introduction 2. Find consecutive ranges and gaps 3. Trouble Ticket roundtrip 4. Grouping on fuzzy criteria 5. Merge temporal intervals
  • 6. 12c SQL Pattern Matching – wann werde ich das benutzen?6 19.11.2015 Introduction
  • 7. Introduction 12c SQL Pattern Matching – wann werde ich das benutzen?7 19.11.2015 Analytic functions Analytic functions enhancements SQL Model Clause LISTAGG NTH_VALUE PIVOT/UNPIVOT clause Pattern Matching Top-N
  • 8. Introduction Oracle 12c database supports SQL Pattern Matching with the new clause - MATCH_RECOGNIZE pattern matching in a sequences of rows nothing to do with string patterns (PL/SQL REGEXP_... functions) it‘s a clause, not a function after the table name in FROM clause patterns are expressed with regular expression syntax over pattern variables pattern variables are defined as SQL expressions 19.11.2015 12c SQL Pattern Matching – wann werde ich das benutzen?8
  • 9. Introduction 19.11.2015 12c SQL Pattern Matching – wann werde ich das benutzen?9 MATCH_RECOGNIZE ( [ PARTITION BY <cols> ] [ ORDER BY <cols> ] [ MEASURES <cols> ] [ ONE ROW PER MATCH | ALL ROWS PER MATCH ] [ SKIP_TO <option> ] PATTERN ( <row pattern> ) [ SUBSET <subset list> ] DEFINE <definition list> )
  • 10. Introduction Example: Find Mappings in the ETL logging table, which were increasingly faster over a period of four days. Output: start and end dates of the period, elapsed time at the beginning and the end of the period, average elapsed time. 19.11.2015 12c SQL Pattern Matching – wann werde ich das benutzen?10
  • 11. Introduction SELECT etl_date, mapping_name, elapsed FROM dwh_etl_runs; ... 04-NOV-14 MAP_STG_S_ORDER_ITEM +000000 00:14:54.42738 05-NOV-14 MAP_STG_S_ORDER +000000 00:10:13.44989 05-NOV-14 MAP_STG_S_ORDER_ITEM +000000 00:15:06.24587 05-NOV-14 MAP_STG_S_ASSET +000000 00:14:15.22855 06-NOV-14 MAP_STG_S_ASSET +000000 00:14:00.49513 06-NOV-14 MAP_STG_S_ORDER +000000 00:11:05.07337 06-NOV-14 MAP_STG_S_ORDER_ITEM +000000 00:10:12.67410 07-NOV-14 MAP_STG_S_ORDER_ITEM +000000 00:19:29.64314 07-NOV-14 MAP_STG_S_ORDER +000000 00:14:59.80953 07-NOV-14 MAP_STG_S_ASSET +000000 00:13:33.80789 08-NOV-14 MAP_STG_S_ASSET +000000 00:10:14.65652 08-NOV-14 MAP_STG_S_ORDER +000000 00:13:30.77744 08-NOV-14 MAP_STG_S_ORDER_ITEM +000000 00:17:15.11789 ... 19.11.2015 12c SQL Pattern Matching – wann werde ich das benutzen?11
  • 12. Introduction 12c SQL Pattern Matching – wann werde ich das benutzen?12 SELECT * FROM dwh_etl_runs MATCH_RECOGNIZE ( PARTITION BY mapping_name ORDER BY etl_date MEASURES FIRST (etl_date) AS start_date , LAST (etl_date) AS end_date , FIRST (elapsed) AS first_elapsed , LAST (elapsed) AS last_elapsed , AVG(elapsed) AS avg_elapsed PATTERN (STRT DOWN{3}) DEFINE DOWN AS elapsed < PREV(elapsed) ) As for analytic functions: partition and order Define measures, which are accessible in the main query Define search pattern with regular expression over boolean pattern variables Define pattern variables Navigation operators: ▪ PREV, NEXT – physical offset ▪ FIRST, LAST – logical offset 19.11.2015
  • 13. Introduction 12c SQL Pattern Matching – wann werde ich das benutzen?13 PATTERN: Subset of Perl syntax for regular expressions – * — 0 or more iterations – + — 1 or more iterations – ? — 0 or 1 iterations – {n} — n iterations (n > 0) – {n,} — n or more iterations (n >= 0) – {n,m} — between n and m (inclusive) iterations (0 <= n <= m, 0 < m) – {,m} — between 0 and m (inclusive) iterations (m > 0) – ( ) – Grouping – | – Alternation – {- … -} – Exclusion – ^ - before the first row in the Partition – $ - after the last row in the partition – ? – “reluctant” vs. “greedy” – …. 19.11.2015
  • 14. Introduction 12c SQL Pattern Matching – wann werde ich das benutzen?14 Patterns are everywhere Financial Telcos Retail Traffic Automotive Transport / Logistics Fraud Detection Quality of Service Trouble Ticketing Price Trends Buying Patterns Stock Market Money Laundering Sensor Data Network Activity Advertising Campaigns Sessionization Frequent Flyer Programms Process Chain CRM 19.11.2015
  • 15. Introduction 12c SQL Pattern Matching – wann werde ich das benutzen?15 SQL had no efficient way to handle such questions pre 12c solutions self-joins, subqueries (NOT) IN, (NOT) EXISTS switch to PL/SQL - „Do it yourself“, often multiple SQL queries transfer some logic to pipelined functions and integrate them in the main query analytic (window) functions – ORA-30483: window functions are not allowed here – not possible to use in WHERE clause – not possible to nest them – unable to access the output of analytic functions in other rows – often leads to nesting queries, self-joins, etc. 19.11.2015
  • 16. Agenda 12c SQL Pattern Matching – wann werde ich das benutzen?16 19.11.2015 1. Introduction 2. Find consecutive ranges and gaps 3. Trouble Ticket roundtrip 4. Grouping on fuzzy criteria 5. Merge temporal intervals
  • 17. 12c SQL Pattern Matching – wann werde ich das benutzen?17 19.11.2015 Find consecutive ranges and gaps
  • 18. Find Consecutive Ranges / Gaps 12c SQL Pattern Matching – wann werde ich das benutzen?18 SLA, QoS: find the longest period without outage Table T_GAPS Find consecutive ranges in the values of column ID Output: Start- and End-ID of consecutive range ID 1 2 3 5 6 10 11 12 14 20 21 … mr_consecutive.sql Start of Range End of Range 1 3 5 6 10 12 19.11.2015
  • 19. Find Consecutive Ranges / Gaps 12c SQL Pattern Matching – wann werde ich das benutzen?19 Pre 12c solution using analytic functionsID 1 2 3 5 6 10 11 12 14 20 21 … WITH groups_marked AS ( SELECT id , CASE WHEN id != LAG(id,1,id) OVER(ORDER BY id) + 1 THEN 1 ELSE 0 END new_grp FROM t_gaps) , sum_grp AS ( SELECT id, SUM(new_grp) OVER(ORDER BY id) grp_sum FROM groups_marked ) SELECT MIN(id) start_of_range , MAX(id) end_of_range FROM sum_grp GROUP BY grp_sum ORDER BY grp_sum; mr_consecutive.sql 19.11.2015
  • 20. Find Consecutive Ranges / Gaps 12c SQL Pattern Matching – wann werde ich das benutzen?20 „Tabibitosan“- method* * - https://community.oracle.com/message/3991177#3991177 ID 1 2 3 5 6 10 11 12 14 20 21 … SELECT MIN(id) start_of_range , MAX(id) end_of_range FROM (SELECT id , id - ROW_NUMBER() OVER(ORDER BY id) distance FROM t_gaps) GROUP BY distance ORDER BY distance; mr_consecutive.sql 19.11.2015
  • 21. Find Consecutive Ranges / Gaps 12c SQL Pattern Matching – wann werde ich das benutzen?21 12c solution with MATCH_RECOGINZEID 1 2 3 5 6 10 11 12 14 20 21 … SELECT * FROM t_gaps MATCH_RECOGNIZE ( ORDER BY id MEASURES FIRST(id) start_of_range , LAST(id) end_of_range , COUNT(*) cnt ONE ROW PER MATCH PATTERN (strt cont*) DEFINE cont AS id = PREV(id)+1 ); mr_consecutive.sql 19.11.2015
  • 22. Find Consecutive Ranges / Gaps 12c SQL Pattern Matching – wann werde ich das benutzen?22 Table T_GAPS, numeric column ID with gaps Find the gaps in the values of column ID Output: start- and end-ID of the gap ID 1 2 3 5 6 10 11 12 14 20 21 … mr_gaps.sql Start of Gap End of Gap 4 4 7 9 13 13 15 19 19.11.2015
  • 23. Find Consecutive Ranges / Gaps 12c SQL Pattern Matching – wann werde ich das benutzen?23 Solution with analytic functions „Tabibitosan“-method* * - https://community.oracle.com/message/3991177#3991177 ID 1 2 3 5 6 10 11 12 14 20 21 … mr_gaps.sql SELECT start_of_gap, end_of_gap FROM ( SELECT id + 1 start_of_gap , LEAD(id) OVER(ORDER BY id) - 1 end_of_gap , CASE WHEN id + 1 != LEAD(id) OVER(ORDER BY id) THEN 1 ELSE 0 END is_gap FROM t_gaps) WHERE is_gap = 1; SELECT MAX(id) + 1 start_of_gap , LEAD(MIN(id)) OVER (ORDER BY distance) -1 end_of_gap FROM (SELECT id , id - ROW_NUMBER() OVER(ORDER BY id) distance FROM t_gaps) GROUP BY distance; 19.11.2015
  • 24. Find Consecutive Ranges / Gaps 12c SQL Pattern Matching – wann werde ich das benutzen?24 12c solution with MATCH_RECOGINZEID 1 2 3 5 6 10 11 12 14 20 21 … mr_gaps.sql SELECT * FROM t_gaps MATCH_RECOGNIZE ( ORDER BY id MEASURES PREV(gap.id)+1 start_of_gap , gap.id - 1 end_of_gap ONE ROW PER MATCH PATTERN (strt gap+) DEFINE gap AS id != PREV(id)+1 ); 19.11.2015
  • 25. Agenda 12c SQL Pattern Matching – wann werde ich das benutzen?25 19.11.2015 1. Introduction 2. Find consecutive ranges and gaps 3. Trouble Ticket roundtrip 4. Grouping on fuzzy criteria 5. Merge temporal intervals
  • 26. 12c SQL Pattern Matching – wann werde ich das benutzen?26 19.11.2015 Trouble Ticket roundtrip
  • 27. Trouble Ticket Roundtrip 12c SQL Pattern Matching – wann werde ich das benutzen?27 SCOTT ADAMS KING ID Assignee Datum 1 SCOTT 01.02.2015 1 SCOTT 02.02.2015 1 ADAMS 03.02.2015 1 SCOTT 04.02.2015 2 ADAMS 01.02.2015 2 ADAMS 02.02.2015 2 SCOTT 03.02.2015 3 KING 01.02.2015 3 ADAMS 02.02.2015 3 ADAMS 03.02.2015 3 KING 04.02.2015 3 ADAMS 05.02.2015 4 KING 01.02.2015 4 ADAMS 02.02.2015 4 SCOTT 03.02.2015 4 KING 05.02.2015 ▪ Find the tickets, which went again to the same assignee 19.11.2015
  • 28. Trouble Ticket Roundtrip 12c SQL Pattern Matching – wann werde ich das benutzen?28 Pre12c solution using self-joins mr_trouble_ticket.sql SELECT DISTINCT t1.ticket_id , t1.assignee AS first_assignee , t3.change_date AS last_change FROM trouble_ticket t1 , trouble_ticket t2 , trouble_ticket t3 WHERE t1.ticket_id = t2.ticket_id AND t1.assignee != t2.assignee AND t2.change_date > t1.change_date AND t3.assignee = t1.assignee AND t3.ticket_id = t1.ticket_id AND t3.change_date > t2.change_date ORDER BY ticket_id 19.11.2015
  • 29. Trouble Ticket Roundtrip 12c SQL Pattern Matching – wann werde ich das benutzen?29 12c solution using MATCH_RECOGINZE clause New: – Row Pattern Skip To: where to start over after match? – match overlaping patterns mr_trouble_ticket.sql SELECT * FROM trouble_ticket MATCH_RECOGNIZE( PARTITION BY ticket_id ORDER BY change_date MEASURES strt.assignee as first_assignee , LAST(same.change_date) as letzte_bearbeitung AFTER MATCH SKIP TO FIRST another PATTERN (strt another+ same+) DEFINE same AS same.assignee = strt.assignee, another AS another.assignee != strt.assignee ); Where to start over after a match is found? 19.11.2015
  • 30. Agenda 12c SQL Pattern Matching – wann werde ich das benutzen?30 19.11.2015 1. Introduction 2. Find consecutive ranges and gaps 3. Trouble Ticket roundtrip 4. Grouping on fuzzy criteria 5. Merge temporal intervals
  • 31. 12c SQL Pattern Matching – wann werde ich das benutzen?31 19.11.2015 Grouping on fuzzy criteria
  • 32. Grouping over fuzzy criteria 12c SQL Pattern Matching – wann werde ich das benutzen?32 „Sessionization“ – Group rows together where the gap between the timestamps is less than defined ... PATTERN (STRT SESS+) DEFINE SESS AS SESS.ins_date – PREV(SESS.ins_date)<= 10/24/60 – Group rows together that are within a defined interval relatively to the first row, otherwise start next group https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID :13946369553642#3478381500346951056 ... PATTERN (A+) DEFINE A AS ins_date < FIRST(ins_date) + 6/24 Group over running totals – Split the data into the groups of defined capacity 19.11.2015
  • 33. Grouping over fuzzy criteria 12c SQL Pattern Matching – wann werde ich das benutzen?33 Example-Schema SH (Sales History) Task: split the data into the group of fixed capacity ▪ Fit all customers ordered by age into groups providing that total sales in every group < 200 000$ 19.11.2015
  • 34. Grouping over fuzzy criteria 12c SQL Pattern Matching – wann werde ich das benutzen?34 12c solution with MATCH_RECOGINZE clause mr_group_running_total.sql WITH q AS (SELECT c.cust_id, c.cust_year_of_birth , SUM(s.amount_sold) cust_amount_sold FROM customers c JOIN sales s ON s.cust_id = c.cust_id GROUP BY c.cust_id, c.cust_year_of_birth ) SELECT * FROM q MATCH_RECOGNIZE( ORDER BY cust_year_of_birth MEASURES MATCH_NUMBER() gruppe , SUM(cust_amount_sold) running_sum , FINAL SUM(cust_amount_sold) final_sum ALL ROWS PER MATCH PATTERN (gr*) DEFINE gr AS SUM(cust_amount_sold)<=200000 ); We need all matches Aggregate function in pattern variable‘s condition function returns the macth number Aggregates in MEASURES: Running vs. Final 19.11.2015
  • 35. Agenda 12c SQL Pattern Matching – wann werde ich das benutzen?35 19.11.2015 1. Introduction 2. Find consecutive ranges and gaps 3. Trouble Ticket roundtrip 4. Grouping on fuzzy criteria 5. Merge temporal intervals
  • 36. 12c SQL Pattern Matching – wann werde ich das benutzen?36 19.11.2015 Merge temporal intervals
  • 37. Merge temporal intervals 12c SQL Pattern Matching – wann werde ich das benutzen?37 Temporal version of SCOTT-Schema: the data in EMP, DEPT and JOB have temporal validity (VALID_FROM - VALID_TO) 19.11.2015
  • 38. Merge temporal intervals 12c SQL Pattern Matching – wann werde ich das benutzen?38 Task: Query the data for one employee joining four tables with respect of temporal validity: 19.11.2015
  • 39. Merge temporal intervals 12c SQL Pattern Matching – wann werde ich das benutzen?39 WITH joined AS ( SELECT e.empno, g.valid_from, LEAST( e.valid_to, d.valid_to, j.valid_to, NVL(m.valid_to, e.valid_to), LEAD(g.valid_from - 1, 1, e.valid_to) OVER( PARTITION BY e.empno ORDER BY g.valid_from ) ) AS valid_to, e.ename, j.job, e.mgr, m.ename AS mgr_ename, e.hiredate, e.sal, e.comm, e.deptno, d.dname FROM empv e INNER JOIN (SELECT valid_from FROM empv UNION SELECT valid_from FROM deptv UNION SELECT valid_from FROM jobv UNION SELECT valid_to + 1 FROM empv WHERE valid_to != DATE '9999-12-31' UNION SELECT valid_to + 1 FROM deptv WHERE valid_to != DATE '9999-12-31' UNION SELECT valid_to + 1 FROM jobv WHERE valid_to != DATE '9999-12-31') g ON g.valid_from BETWEEN e.valid_from AND e.valid_to INNER JOIN deptv d ON d.deptno = e.deptno AND g.valid_from BETWEEN d.valid_from AND d.valid_to INNER JOIN jobv j ON j.jobno = e.jobno AND g.valid_from BETWEEN j.valid_from AND j.valid_to LEFT JOIN empv m ON m.empno = e.mgr AND g.valid_from BETWEEN m.valid_from AND m.valid_to ) ... Quelle: Philipp Salvisberg: http://www.salvis.com/blog/2012/12/28/joining-temporal-intervals-part-2/ 19.11.2015
  • 40. Merge temporal intervals 12c SQL Pattern Matching – wann werde ich das benutzen?40 ... SELECT empno, valid_from, valid_to, ename, job, mgr, mgr_ename, hiredate, sal, comm, deptno, dname FROM joined MATCH_RECOGNIZE ( PARTITION BY empno, ename, job, mgr, mgr_ename, hiredate, sal, comm, deptno, dname ORDER BY valid_from MEASURES FIRST(valid_from) valid_from, LAST(valid_to) valid_to PATTERN ( strt nxt* ) DEFINE nxt as valid_from = prev(valid_to) + 1 ) WHERE empno = 7788; 19.11.2015
  • 41. Conclusion 12c SQL Pattern Matching – wann werde ich das benutzen?41 Very powerful feature Significantly simplifies a lot of queries (self-joins, semi-, anti-joins, nested queries), mostly with performance benefit Since 2007 a proposal for ANSI-SQL Requires thinking in patterns Complicated syntax (at first sight ) But in many cases the code looks like the requirement in „plain English“ 19.11.2015
  • 42. Further information... 12c SQL Pattern Matching – wann werde ich das benutzen?42 Database Data Warehousing Guide - SQL for Pattern Matching - http://docs.oracle.com/database/121/DWHSG/pattern.htm#DWHSG8956 Stewart Ashton‘s Blog - https://stewashton.wordpress.com Oracle Whitepaper - Patterns everywhere - Find them Fast! - http://www.oracle.com/ocom/groups/public/@otn/documents/webcontent/1965433.pdf 19.11.2015
  • 43. 12c SQL Pattern Matching – wann werde ich das benutzen?43 19.11.2015 Trivadis an der DOAG 2015 Ebene 3 - gleich neben der Rolltreppe Wir freuen uns auf Ihren Besuch. Denn mit Trivadis gewinnen Sie immer.