{"id":690705,"date":"2020-09-10T05:33:59","date_gmt":"2020-09-10T12:33:59","guid":{"rendered":"https:\/\/www.microsoft.com\/en-us\/research\/?post_type=msr-project&p=690705"},"modified":"2020-10-08T09:16:56","modified_gmt":"2020-10-08T16:16:56","slug":"aggify","status":"publish","type":"msr-project","link":"https:\/\/www.microsoft.com\/en-us\/research\/project\/aggify\/","title":{"rendered":"Aggify"},"content":{"rendered":"
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 with regard to performance, resource consumption and concurrency.<\/p>\n
Aggify is a technique for optimizing loops over query results that overcomes 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:<\/p>\n
Aggify integrates seamlessly with Froid<\/a> thereby enabling Froid-style inlining for UDFs with cursor loops.<\/p>\n\t\t\t