Fast Subsequence Matching in Time-Series Databases

Christos Faloutsos, M. Ranganathan, Yannis Manolopoulos

Introduction

As time-series databases—containing stock prices, sensor logs, or weather patterns—grow to massive scales, the ability to efficiently find specific patterns becomes critical. While "whole matching" (comparing two sequences of identical length) is a well-studied problem, "subsequence matching" presents a greater challenge. In this scenario, the goal is to find all occurrences of a query pattern $Q$ within a much longer data sequence $S$, even when the lengths differ or the data contains noise.

Traditional sequential scanning is computationally expensive for modern datasets. This paper introduces the ST-index (Sub-Trail index), a novel method that transforms the time-series matching problem into a spatial indexing problem, achieving search speeds up to 100 times faster than brute-force methods.

The ST-index Method

The ST-index relies on a multi-step process to index time-series data efficiently:

  1. Feature Extraction: A sliding window of size $w$ moves across the time series. For each window, the Discrete Fourier Transform (DFT) is applied. By retaining only the first few coefficients, each window is mapped to a point in a low-dimensional feature space.
  2. Trail Representation: Because successive sliding windows differ by only one data point, their corresponding points in feature space change slowly, forming a smooth "trail."
  3. MBR Grouping: Storing every point in the trail would lead to an excessively large index. Instead, the ST-index breaks these trails into "sub-trails" and encapsulates them within Minimum Bounding Rectangles (MBRs).
  4. Spatial Indexing: These MBRs are then stored in an $R^*$-tree, a standard structure for high-performance spatial searching.
Trails and Minimum Bounding Rectangles (MBRs) in feature space. (a) shows the smooth trails formed by sliding windows, while (b) demonstrates how these trails are grouped into MBRs for indexing.

To handle queries longer than the window size $w$, the authors developed the MultiPiece algorithm. This algorithm decomposes a long query into $p$ pieces of length $w$, searching for each with a reduced tolerance to ensure that no valid matches are missed.

Key Insights and Mathematical Guarantees

The effectiveness of the ST-index stems from two primary insights:

  • Trail Smoothness: The high correlation between overlapping windows ensures that the data forms manageable trails rather than a chaotic cloud of points. This allows for efficient grouping into MBRs.
  • No False Dismissals: By utilizing Parseval’s Theorem, the authors prove that the distance between two points in the reduced feature space is always less than or equal to their distance in the original time-series space. This "lower bounding" property ensures that while the index may return "false alarms" (which are later filtered), it will never miss a true match.

Results and Performance

The ST-index was evaluated using both real-world stock price data (329,000 points) and synthetic random-walk data (500,000 points). The results demonstrate significant improvements over sequential scanning:

  • Speed: The ST-index achieved speedups ranging from 3x to 100x, depending on query selectivity.
  • Space Efficiency: An adaptive heuristic for trail breaking proved highly effective. In one experiment, the ST-index reduced the index size from a naive 24 MB to just 5 KB—a 4,800x reduction.

Conclusion

The ST-index provides a robust and scalable solution for subsequence matching in large time-series databases. By leveraging the "smoothness" of sliding windows and the efficiency of $R^*$-trees, it offers a dramatic improvement over sequential scanning. Future work may involve extending these techniques to higher-dimensional data, such as medical imaging or 2D vector fields.

Summary updated

BibTeX
@inproceedings{faloutsos1994fast,
  author = {Christos Faloutsos and M. Ranganathan and Yannis Manolopoulos},
  title = {{Fast Subsequence Matching in Time-Series Databases}},
  booktitle = {SIGMOD},
  year = {1994},
  doi = {10.1145/191839.191925},
}
Figure