Fast and Exact Similarity Search in less than a Blink of an Eye

Patrick Schäfer, Jakob Brand, Ulf Leser, Botao Peng, Themis Palpanas

TL;DR

The SOFA (SymbOlic Fourier Approximation) index is a new state-of-the-art for exact similarity search in massive data series datasets. By replacing standard mean-based summarization with a learned, frequency-domain approach, SOFA achieves search speeds up to 38x faster than previous methods, enabling exact queries across a billion data points in "less than a blink of an eye."

What Problem Does This Paper Address?

Similarity search—finding the closest match to a query in a massive database—is the engine behind everything from earthquake detection to financial anomaly analysis. To handle billions of data series (DS), researchers use "summarization" to reduce dimensionality and "indexing" to prune the search space.

The current gold standard, SAX (Symbolic Aggregate approXimation), has two major weaknesses:

  1. High-Frequency Blindness: It summarizes data by taking mean values over segments. For noisy or high-frequency signals, this "low-pass filter" effect turns a complex signal into a flat line, losing the very details needed to distinguish between series.
  2. Rigid Assumptions: SAX assumes data follows a Normal (Gaussian) distribution. Real-world data—like seismic waves or astronomical signals—often breaks this assumption, leading to poor indexing performance.

As shown in Figure 1, SAX's mean-based approach (orange) fails to capture the essence of high-frequency signals compared to a Fourier-based approach (blue).

Comparison of PAA (SAX) vs FFT (SFA) and value distributions

Methods

The authors introduce SOFA, which combines a high-performance tree index with a novel application of Symbolic Fourier Approximation (SFA).

1. Learned Symbolic Representation (SFA)

Instead of time-domain averaging, SFA uses the Discrete Fourier Transform (DFT). Key innovations include:

  • Variance-Based Feature Selection: Rather than just keeping the lowest frequencies, SOFA selects Fourier coefficients with the highest variance across the dataset. This ensures the index focuses on the most "discriminative" parts of the signal.
  • Multiple Coefficient Binning (MCB): SOFA doesn't assume a Gaussian distribution. It samples 1% of the data to learn the actual distribution of each Fourier coefficient and creates custom quantization bins accordingly.

2. The SOFA Index

The index is built on a parallel tree structure (inspired by the MESSI index) optimized for modern hardware.

  • GEMINI Framework: It uses the "lower-bounding" property, where a distance calculated on the summarized data is guaranteed to be less than or equal to the true Euclidean distance. This allows the system to safely discard millions of candidates without ever looking at their raw values.
  • SIMD Optimization: The authors developed a novel way to calculate these complex Fourier-based lower bounds using SIMD (Single Instruction, Multiple Data). They use bitmasks to handle the conditional branching required for distance calculations, as illustrated in Figure 6.
SIMD lower bound distance calculation using bitmaps

Datasets

The study introduces a massive new benchmark comprising 17 diverse datasets totaling 1 billion data series (1TB of data).

  • Seismology: 12 datasets (e.g., LenDB, SCEDC, ETHZ) containing seismic wave recordings.
  • Astronomy & Neuroscience: Standard benchmarks like Astro and SALD.
  • Vector Data: High-dimensional embeddings like Deep1B and SIFT1b.

Key Insights and Ideas

  • Frequency is King for Complexity: For signals with high variability, the frequency domain provides a much tighter "lower bound" than the time domain. A tighter bound means more candidates can be pruned, leading to faster searches.
  • Variance as a Proxy for Information: By prioritizing Fourier coefficients with high variance, the authors prove that you can capture the "semantics" of a signal more effectively than traditional low-pass filtering.
  • Data-Adaptive Quantization: Learning the bins from the data (MCB) is crucial. Figure 1 (bottom) shows that real-world data distributions are rarely perfectly Gaussian; adapting to the actual "shape" of the data significantly improves pruning power.

Key Results

SOFA consistently outperformed all competitors, including the previous state-of-the-art MESSI and the popular FAISS library:

  • Speed: SOFA is up to 10x faster than a parallel sequential scan and 2-3x faster than MESSI on average.
  • High-Frequency Performance: On the LenDB seismic dataset, SOFA was a staggering 38x faster than MESSI.
  • Latency: An exact 1-NN query on a billion series takes just 58ms (median), truly faster than a human blink.
  • Scalability: The method scales efficiently with both the number of CPU cores and the number of nearest neighbors ($k$) requested.

Limitations and Future Work

  • Index Creation Overhead: SOFA takes slightly longer to build its index than SAX-based methods because it must perform DFTs and learn quantization bins from a data sample. However, the authors argue this is a one-time cost that pays off immensely during querying.
  • Future Directions: The authors plan to explore approximate similarity search using SFA (which could be even faster) and further acceleration using GPUs.

For those interested in the implementation, the authors have made their code and notebooks available online.

Summary updated

BibTeX
@inproceedings{schafer2025fast,
  author = {Patrick Schäfer and Jakob Brand and Ulf Leser and Botao Peng and Themis Palpanas},
  title = {{Fast and Exact Similarity Search in less than a Blink of an Eye}},
  booktitle = {ICDE},
  year = {2025},
  doi = {10.1109/icde65448.2025.00186},
}
Figure