High-Performance Row Pattern Recognition Using Joins
Erkang Zhu, Silu Huang, Surajit Chaudhuri
Abstract
The SQL standard introduced MATCH_RECOGNIZE in 2016 for row pattern recognition. Since then, MATCH_RECOGNIZE has been supported by several leading relation systems, they implemented this function using Non-Deterministic Finite Automaton (NFA). While NFA is suitable for pattern recognition in streaming scenarios, the current uses of NFA by the relational systems for historical data analysis scenarios overlook important optimization opportunities. We propose a new approach to use Join to speed up row pattern recognition in historical analysis scenarios for relational systems. Implemented as a logical plan rewrite rule, the new approach first filters the input relation to MATCH_RECOGNIZE using Joins constructed based on a subset of symbols taken from the PATTERN expression, then run the NFA-based MATCH_RECOGNIZE on the filtered rows, reducing the net cost. The rule also includes a specialized cardinality model for the Joins and a cost model for the NFA-based MATCH_RECOGNIZE operator for choosing an appropriate symbol set. The rewrite rule is applicable when the query pattern's definition is self-contained and either the input table has no duplicates or there is a window condition. Applying the rewrite rule to a query benchmark with 1,800 queries spanning over 6 patterns and 3 pattern definitions, we observed median speedups of 5.4X on Trino (v373 with ORC files on Hive), 57.5X on SQL Server (2019) using column store and 41.6X on row store.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext a1d5850c-b1bf-4424-b1c2-bb69eb61f2e0Cited by top-tier papers4
- Complex Event Recognition with Symbolic Register TransducersElias Alevizos, Alexander Artikis, Georgios PaliourasVLDB 2024 · 6 citations
- LLMLog: Advanced Log Template Generation via LLM-driven Multi-Round AnnotationFei Teng, Haoyang Li, Lei ChenVLDB 2025 · 2 citations
- ACER: Accelerating Complex Event Recognition via Two-Phase Filtering under Range Bitmap-Based IndexesShizhe Liu, Haipeng Dai, Shaoxu Song, Meng Li et al.KDD 2024 · 2 citations
- SHARP: Shared State Reduction for Efficient Matching of Sequential PatternsCong Yu, Tuo Shi, Matthias Weidlich, Bo ZhaoVLDB 2026
Builds on4
- Adopting Worst-Case Optimal Joins in Relational Database SystemsMichael J. Freitag, Maximilian Bandle, Tobias Schmidt, Alfons Kemper et al.VLDB 2020 · 79 citations
- Index-Accelerated Pattern Matching in Event StoresMichael Körber, Nikolaus Glombiewski, Bernhard SeegerSIGMOD 2021 · 9 citations
- Near-Optimal Distributed Band-Joins through Recursive PartitioningRundong Li, Wolfgang Gatterbauer, Mirek RiedewaldSIGMOD 2020 · 8 citations
- A Scalable and Generic Approach to Range JoinsMaximilian Reif, Thomas NeumannVLDB 2022 · 6 citations
Related papers
- T-Rex: Optimizing Pattern Search on Time SeriesSilu Huang, Erkang Zhu, Surajit Chaudhuri, Leonhard SpiegelbergSIGMOD 2023 · 16 citations
- WeTune: Automatic Discovery and Verification of Query Rewrite RulesZhaoguo Wang, Zhou Zhou, Yicun Yang, Haoran Ding et al.SIGMOD 2022 · 35 citations
- Window Function Optimization: Co-Evaluation and Other TechniquesDaniel Lindner, Felix Naumann, Alberto LernerVLDB 2026
- PLAQUE: Automated Predicate Learning at Query TimeYiming Lin, Sharad MehrotraSIGMOD 2024 · 2 citations
- Towards a Converged Relational-Graph Optimization FrameworkYunkai Lou, Longbin Lai, Bingqing Lyu, Yufan Yang et al.SIGMOD 2025 · 4 citations
