Skip to main content
QUICK REVIEW

[Paper Review] Query shredding: Efficient relational evaluation of queries over nested multisets (extended version)

James Cheney, Sam Lindley|arXiv (Cornell University)|Apr 28, 2014
Advanced Database Systems and QueriesComputer Science33 references15 citations
TL;DR

This paper presents a novel query shredding technique that efficiently translates nested multiset queries into a fixed number of flat SQL queries while preserving bag semantics. By leveraging normalization, indexed shredding, and delayed OLAP operations, the approach outperforms prior methods like loop-lifting in performance benchmarks on moderate-sized databases.

ABSTRACT

Nested relational query languages have been explored extensively, and underlie industrial language-integrated query systems such as Microsoft's LINQ. However, relational databases do not natively support nested collections in query results. This can lead to major performance problems: if programmers write queries that yield nested results, then such systems typically either fail or generate a large number of queries. We present a new approach to query shredding, which converts a query returning nested data to a fixed number of SQL queries. Our approach, in contrast to prior work, handles multiset semantics, and generates an idiomatic SQL:1999 query directly from a normal form for nested queries. We provide a detailed description of our translation and present experiments showing that it offers comparable or better performance than a recent alternative approach on a range of examples.

Motivation & Objective

  • To address the performance bottleneck in language-integrated query systems like LINQ and Ferry, where nested queries cause query storms or inefficient in-memory evaluation.
  • To enable efficient, relational evaluation of nested queries over multisets (bags), which prior systems often fail to handle correctly or efficiently.
  • To develop a translation pipeline that generates idiomatic, optimizable SQL:1999 queries without relying on complex query optimizers post-translation.
  • To preserve multiset semantics during shredding, avoiding quadratic blowup in result size seen in prior approaches.

Proposed method

  • The method begins with normalizing nested queries into a higher-order normal form, eliminating higher-order features and enabling modular translation.
  • A shredding phase decomposes the normalized query into a shredded package of flat SQL queries, annotated with indexes that link nested levels via foreign keys.
  • A let-insertion phase introduces SQL-compatible indexing using ROW_NUMBER and WITH clauses to represent abstract indexes as concrete, flat relational constructs.
  • The final translation phase maps the shredded package to standard SQL:1999, flattening records and embedding row-numbering operations directly into the query plan.
  • The approach delays use of advanced OLAP features (e.g., ROW_NUMBER) until the final SQL generation, improving compatibility and optimization potential.
  • The system is implemented and evaluated against loop-lifting on synthetic benchmarks, using standard SQL optimizers without additional query rewriters.

Experimental results

Research questions

  • RQ1Can nested multiset queries be efficiently translated into a fixed number of flat SQL queries while preserving bag semantics?
  • RQ2How can a normalization-based approach enable modular, composable translation from nested queries to flat relational form?
  • RQ3Does deferring OLAP operations (e.g., ROW_NUMBER) until the final SQL phase improve performance and compatibility with standard SQL optimizers?
  • RQ4How does the proposed shredding method compare to loop-lifting in terms of query execution performance and result size?
  • RQ5Can the approach be generalized to other language-integrated query systems such as LINQ or Ferry, or to complex-object query languages?

Key findings

  • The proposed shredding method achieves comparable or better performance than loop-lifting on a range of synthetic benchmark queries over databases up to 500MB in size.
  • The method preserves multiset semantics, avoiding the quadratic blowup in result size that can occur in prior approaches when handling unions of nested bags.
  • By deferring OLAP operations until the final SQL translation, the approach generates more predictable and optimizable SQL plans, reducing reliance on complex post-translation optimizers.
  • The implementation supports efficient execution without requiring additional query rewriting tools like Pathfinder, unlike Ferry’s loop-lifting approach.
  • The method is extensible to list-based semantics, though current implementation focuses on bag semantics matching SQL’s default behavior.
  • The approach is compatible with existing SQL:1999 features and can be integrated into systems like LINQ or Ferry with minimal changes.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.