Cortex: Harnessing Correlations to Boost Query Performance

Vikram Nathan, Jialin Ding, Tim Kraska, Mohammad AlizadeharXiv 2020

Abstract

Databases employ indexes to filter out irrelevant records, which reduces scan overhead and speeds up query execution. However, this optimization is only available to queries that filter on the indexed attribute. To extend these speedups to queries on other attributes, database systems have turned to secondary and multi-dimensional indexes. Unfortunately, these approaches are restrictive: secondary indexes have a large memory footprint and can only speed up queries that access a small number of records, and multi-dimensional indexes cannot scale to more than a handful of columns. We present Cortex, an approach that takes advantage of correlations to extend the reach of primary indexes to more attributes. Unlike prior work, Cortex can adapt itself to any existing primary index, whether single or multi-dimensional, to harness a broad variety of correlations, such as those that exist between more than two attributes or have a large number of outliers. We demonstrate that on real datasets exhibiting these diverse types of correlations, Cortex matches or outperforms traditional secondary indexes with $5\times$ less space, and it is $2-8\times$ faster than existing approaches to indexing correlations.

Introduction

In modern database systems, a fundamental trade-off exists between query speed and storage overhead. Primary indexes, such as sorted columns or B-Trees, offer exceptional performance by physically organizing data. However, a table can typically only support one primary index. To maintain efficiency for queries on non-primary attributes, systems rely on secondary indexes.

Secondary indexes suffer from two critical limitations. First, they impose a significant memory footprint, often consuming more space than the data itself. Second, they are susceptible to the "random access penalty." While effective for high-selectivity queries (returning few records), their performance degrades rapidly as selectivity decreases, eventually becoming slower than a full table scan due to the overhead of non-sequential memory access.

Methodology: The Cortex Framework

Cortex addresses these challenges by leveraging data correlations—relationships where the value of one attribute can help predict another (e.g., Zip Code and City). Unlike previous correlation-based methods that relied on rigid linear models, Cortex is "model-free" and performance-driven.

Performance-Based Outlier Stashing

Cortex divides data into "inliers" and "outliers." Crucially, it defines outliers based on query latency rather than statistical deviation. If a record is cheaper to retrieve from a small secondary "stash" than by scanning a range in the primary index, it is classified as an outlier and stashed. This allows Cortex to adapt to any data distribution, whether linear, categorical, or complex.

Host Index Agnosticism

Cortex is designed to "harness" any existing primary index. It works seamlessly with 1D sorted structures or multi-dimensional indexes like Octrees or Z-order curves. By indexing columns independently while leveraging shared information, it avoids the exponential slowdowns typical of traditional multi-dimensional approaches.

Experimental Setup and Datasets

The effectiveness of Cortex was evaluated using four diverse datasets, representing various correlation types:

  • Stocks (165M rows): Strong linear correlations (e.g., Daily High vs. Daily Open).
  • Chicago Taxi (194M rows): "Messy" and non-functional relationships (e.g., Trip Distance vs. Fare).
  • WISE Astronomy (198M rows): Complex multi-way correlations in celestial coordinates.
  • Synthetic Data (100M rows): Used to test scalability and noise robustness.
Diverse correlation patterns across real-world datasets.

Discussion and Key Insights

A major breakthrough in Cortex is its ability to overcome the "Curse of Dimensionality." Traditional multi-dimensional indexes see performance drop off sharply as the number of indexed columns increases. Cortex maintains efficiency by decoupling the indexing of attributes while still exploiting their underlying correlations.

The performance impact of the curse of dimensionality on traditional indexing.

Furthermore, Cortex exhibits organic transitions between point lookups and range scans. As query selectivity changes, the system naturally shifts its retrieval strategy to ensure optimal performance across diverse workloads.

Key Results

  • Space Efficiency: Cortex achieves B-Tree-level performance while requiring 5x to 70x less memory.
  • Query Speed: The system is 2x to 8x faster than state-of-the-art correlation-based indexes like Hermit or Correlation Maps.
  • Robustness: Cortex remains performant even in high-noise environments (up to 80% noise) and scales linearly to 45+ columns, whereas traditional methods fail due to memory constraints.

Conclusion and Future Work

While Cortex offers significant advantages, it faces challenges with high-frequency updates, as reclassifying records between inliers and outliers can be computationally expensive. Future research will focus on automating the adjustment of the cost model ($\beta$) and the space-speed tradeoff parameter ($\alpha$) to maintain optimal performance dynamically as data evolves.

Summary updated

BibTeX
@misc{nathan2020cortex,
  author = {Vikram Nathan and Jialin Ding and Tim Kraska and Mohammad Alizadeh},
  title = {{Cortex: Harnessing Correlations to Boost Query Performance}},
  year = {2020},
  eprint = {2012.06683},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2012.06683},
}
Figure