Microsoft Corporation
OPTIMIZING CURSOR LOOPS IN RELATIONAL DATABASE SYSTEMS USING CUSTOM AGGREGATES

Last updated:

Abstract:

Methods and systems are provided for converting a loop (e.g., a cursor loop) to a declarative Structured Query Language (SQL) query that invokes a custom aggregate function. The loop includes a select query and a loop body that includes a program fragment that can be evaluated over a result set of the select query one row at a time. The system verifies that the loop body does not modify a persistent state of the database. A custom aggregate function that expresses the loop body is automatically constructed according to a contract. An aggregate class comprising aggregation methods of the contract are used to construct the aggregate function based on results of static analysis. The select query is automatically rewritten to form a declarative SQL query that invokes the custom aggregate function. The declarative SQL query may be executed by a database management system (DBMS) SQL server.

Status:
Application
Type:

Utility

Filling date:

24 Jul 2020

Issue date:

27 Jan 2022