KV-match: An Efficient Subsequence Matching Approach for Large Scale Time Series

Jiaye Wu, Peng Wang, Chen Wang, Wei Wang, Jianmin Wang

Abstract

Subsequence matching in massive time series datasets is a fundamental task in data science, yet it has long been hindered by a trade-off between search efficiency and normalization flexibility. While Raw Subsequence Matching (RSM) allows for efficient indexing, it fails to capture shape-based similarities. Conversely, Normalized Subsequence Matching (NSM) captures shape but has traditionally been considered "un-indexable," requiring exhaustive scans. This paper presents KV-match, a high-performance indexing approach that bridges this gap. By introducing a constrained normalization model (cNSM) and a 1-D key-value index based on windowed means, KV-match enables trillion-scale searches that are up to three orders of magnitude faster than state-of-the-art sequential scan methods like the UCR Suite.

1. Introduction

Time series subsequence matching—the process of finding a specific pattern within a continuous data stream—is essential for applications ranging from medical monitoring to financial analysis. Historically, researchers have navigated two distinct paths: indexing raw values (RSM) using structures like R-trees, or performing z-normalized searches (NSM) to find patterns with similar shapes regardless of scale.

However, NSM faces two primary challenges. First, the computational cost is immense; the current gold standard, the UCR Suite, requires a full dataset scan for every query. Second, "pure" normalization can be overly aggressive, sometimes equating distinct physical states (e.g., sitting vs. lying down in sensor data) simply because their normalized shapes are similar. There is a clear need for a system that provides the efficiency of an index while maintaining the semantic flexibility of normalization.

2. Methodology

2.1 Constrained Normalization (cNSM)

To address the limitations of pure normalization, the authors propose the constrained Normalized Subsequence Matching (cNSM) model. This model introduces two user-defined "knobs": $\alpha$ for amplitude scaling and $\beta$ for offset shifting. By constraining these parameters, users can search for similar shapes within a realistic physical range, preventing the false positives associated with extreme scaling while providing the mathematical "slack" necessary for indexing.

2.2 The KV-index

Rather than relying on complex multi-dimensional tree structures that perform poorly on modern hardware due to random disk seeks, KV-match utilizes a KV-index. This is a 1-D index built on the mean values of sliding windows. The authors provide a mathematical proof that if a subsequence matches a query under cNSM, its windowed mean must fall within a specific, calculable range. This allows the system to use a simple, sorted list of key-value pairs, facilitating efficient sequential scans that align with the architecture of modern SSDs and distributed databases like HBase or Cassandra.

2.3 KV-matchDP

To further optimize performance, the authors developed KV-matchDP. This advanced version utilizes multiple indexes with varying window lengths (e.g., 25, 50, 100). It employs a dynamic programming approach to determine the optimal way to decompose a query into segments, minimizing the number of candidates retrieved from the index and maximizing pruning power.

3. Experimental Evaluation

3.1 Datasets

The approach was evaluated using a combination of real-world and synthetic data:

  • Real-world: The PAMAP (Physical Activity Monitoring) dataset and the UCR Archive.
  • Synthetic: Massive datasets containing up to 1 trillion data points, generated using random walks and Gaussian distributions to test the limits of scalability.

3.2 Performance Results

KV-match demonstrated remarkable efficiency across all benchmarks:

  • Scalability: On the 1-trillion point dataset, KV-matchDP processed queries in 127 seconds for Euclidean Distance and 243 seconds for Dynamic Time Warping (DTW). In contrast, a non-indexed scan of such data would take days.
  • Speedup: The system outperformed the UCR Suite by 2 to 3 orders of magnitude on large-scale synthetic data.
  • Storage Efficiency: The index is highly compact, typically requiring only 10% of the storage space of the original raw data.
  • Pruning Power: While a single window might return many potential matches, the intersection of multiple windows (the "KV-match" algorithm) effectively narrows the search to exact matches with minimal overhead.

4. Discussion and Limitations

A key insight of this work is that a single-dimensional feature—the windowed mean—is sufficient to prune the vast majority of non-matching candidates, even for complex distance measures. By prioritizing sequential access over random access, KV-match adapts subsequence matching for the era of big data and distributed systems.

Despite its strengths, the approach has limitations. The window lengths are fixed at the time of index construction, which may affect performance for queries that do not align well with those lengths. Additionally, the effectiveness of the search depends on the user's ability to provide appropriate $\alpha$ and $\beta$ constraints, requiring some degree of domain expertise.

5. Conclusion

KV-match represents a significant advancement in time series indexing. By combining a constrained normalization model with a hardware-friendly key-value index, it enables z-normalized subsequence matching at a scale previously thought impossible. Future work will focus on supporting a broader range of distance measures and exploring variable-length DTW support.

Summary updated

BibTeX
@inproceedings{wu2019kv,
  author = {Jiaye Wu and Peng Wang and Chen Wang and Wei Wang and Jianmin Wang},
  title = {{KV-match: An Efficient Subsequence Matching Approach for Large Scale Time Series}},
  booktitle = {ICDE},
  year = {2019},
  doi = {10.1109/icde.2019.00082},
}
Figure