Cohort Query Processing

Dawei Jiang, Qingchao Cai, Gang Chen, H. V. Jagadish, Beng Chin Ooi, Kian-Lee Tan, Anthony K. H. Tung

TL;DR

This paper introduces COHANA, a novel columnar database engine designed for efficient cohort analysis. By extending SQL with new operators and a specialized storage format, COHANA significantly outperforms traditional SQL and materialized view approaches for analyzing user behavior trends, achieving up to two orders of magnitude speedup.

What Problem Does This Paper Address?

Modern internet applications generate vast amounts of user activity data. Analyzing this data to understand user behavior trends, a process known as cohort analysis, is crucial for businesses aiming to increase sales and user retention. Traditional methods, like using SQL's GROUP BY operator, are cumbersome to express and computationally expensive for cohort analysis. Furthermore, existing approaches often struggle to handle more complex cohort definitions, such as filtering based on attributes other than time or analyzing subsets of data. This paper addresses the need for a database system that can efficiently and elegantly support generalized cohort analysis.

Methods

The authors propose several key innovations:

  • Extended SQL Operators: Three new SQL operators (σ_{C,e}, σ'_{C,e}, and γ_{L,e,f}) are introduced to model cohort analysis operations: birth selection, age selection, and cohort aggregation, respectively. These operators allow for more expressive and concise cohort queries.
  • Columnar Storage Format: A specialized columnar storage format is designed for activity tables. This format leverages techniques like Run-Length Encoding (RLE), two-level compression, and delta encoding to efficiently store and access user activity data, particularly for birth and age-related queries.
  • COHANA Engine: A columnar query engine, COHANA, is built to implement these new operators and storage formats. It includes optimizations like pushing down birth selection operators and a modified TableScan operator for efficient data retrieval.
  • Non-Intrusive Approaches: The paper also discusses two non-intrusive approaches: a pure SQL-based method and a materialized view (MV) based method, serving as baselines for comparison.

Datasets

The paper uses a real-world mobile game activity dataset. This dataset consists of 30 million activity tuples from over 57,000 users, spanning from May 19, 2013, to June 26, 2013. It includes attributes like user ID, action, timestamp, country, city, role, session length, and gold spent. The authors also mention scaling this dataset for experiments. No new benchmarks were introduced; instead, existing query types were adapted for cohort analysis.

Key Insights and Ideas

  • Cohort Analysis is More Than Just Grouping: The paper highlights that traditional GROUP BY is insufficient for cohort analysis, which requires understanding user behavior over time relative to a specific "birth" event.
  • Generalized Cohort Definitions are Crucial: The ability to define cohorts based on attributes beyond just time (e.g., country, role) and to filter data based on these birth attributes is essential for deeper insights.
  • Columnar Storage is Key for Performance: The specialized columnar storage format, combined with intelligent compression and access strategies, is fundamental to COHANA's performance gains.
  • Pushing Down Selections is Vital: Optimizing query plans by pushing birth selection operators down the query tree significantly reduces the amount of data processed.
  • Dedicated Engines Outperform General-Purpose Databases: The experimental results strongly suggest that a specialized engine like COHANA is far more efficient for cohort analysis than adapting general-purpose relational databases.

Key Results

  • COHANA achieves performance improvements of up to two orders of magnitude compared to traditional SQL-based approaches and one to two orders of magnitude faster than materialized view approaches on relational databases.
  • The performance of COHANA scales well with dataset size, outperforming even a state-of-the-art columnar database (MonetDB) with materialized views on large datasets.
  • The paper demonstrates that the performance of COHANA is sensitive to the selectivity of birth conditions, aligning with the theoretical O(n) complexity where n is the number of qualified users.
  • The generation of materialized views for cohort analysis is significantly more expensive (hours to days) than COHANA's data compression process (hours for large datasets).

Limitations and Future Work

  • Mixed Querying: While the paper briefly touches upon mixing cohort queries with standard SQL queries, a full implementation and detailed performance study are left for future work.
  • Binary Cohort Operators: The extension to handle multiple activity tables using binary operators (join, intersection) is mentioned as future work.
  • Further Optimization: The authors suggest exploring more advanced compression techniques and query optimization strategies.
  • Broader Applications: The paper aims to generalize cohort analysis for a wider spectrum of applications beyond typical user retention analysis.

Summary updated

BibTeX
@article{jiang2016cohort,
  author = {Dawei Jiang and Qingchao Cai and Gang Chen and H. V. Jagadish and Beng Chin Ooi and Kian-Lee Tan and Anthony K. H. Tung},
  title = {{Cohort Query Processing}},
  journal = {Proc. VLDB Endow.},
  year = {2016},
  url = {https://openreview.net/forum?id=sT6nNqr7ed},
}
Figure