Optimizing Cursor Loops in Relational Databases

04/11/2020
by   Surabhi Gupta, et al.
0

Loops that iterate over SQL query results are quite common, both in application programs that run outside the DBMS, as well as User Defined Functions (UDFs) and stored procedures that run within the DBMS. It can be argued that set-oriented operations are more efficient and should be preferred over iteration; but from real-world use cases, it is clear that loops over query results are inevitable in many situations, and are preferred by many users. Such loops, known as cursor loops, come with huge trade-offs and overheads w.r.t. performance, resource consumption and concurrency. We present Aggify, a technique for optimizing loops over query results that overcomes all these overheads. It achieves this by automatically generating custom aggregates that are equivalent in semantics to the loop. Thereby, Aggify completely eliminates the loop by rewriting the query to use this generated aggregate. This technique has several advantages such as: (i) pipelining of entire cursor loop operations instead of materialization, (ii) pushing down loop computation from the application layer into the DBMS, closer to the data, (iii) leveraging existing work on optimization of aggregate functions, resulting in efficient query plans. We describe the technique underlying Aggify and present our experimental evaluation over benchmarks as well as real workloads that demonstrate the significant benefits of this technique.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
12/01/2017

Optimization of Imperative Programs in a Relational Database

For decades, RDBMSs have supported declarative SQL as well as imperative...
research
03/23/2017

Flare: Native Compilation for Heterogeneous Workloads in Apache Spark

The need for modern data analytics to combine relational, procedural, an...
research
07/19/2021

Optimal Resource Allocation for Serverless Queries

Optimizing resource allocation for analytical workloads is vital for red...
research
08/05/2023

Dataopsy: Scalable and Fluid Visual Exploration using Aggregate Query Sculpting

We present aggregate query sculpting (AQS), a faceted visual query techn...
research
08/27/2020

Cost-based Query Rewriting Techniques for Optimizing Aggregates Over Correlated Windows

Window aggregates are ubiquitous in stream processing. In Azure Stream A...
research
09/21/2020

Towards application-specific query processing systems

Database systems use query processing subsystems for enabling efficient ...
research
05/18/2022

A Novel Loop Fission Technique Inspired by Implicit Computational Complexity

This work explores an unexpected application of Implicit Computational C...

Please sign up or login with your details

Forgot password? Click here to reset