Modern web applications are frequently built using object-relational mapping (ORM) frameworks. Such frameworks aim to provide transparent access to the database by allowing developers express persistent data accesses using the same language as the application. Unfortunately, due to a variety of reasons, developers often write application code that does not take advantage of the optimized relational implementations that database systems provide, and the ORM framework cannot optimize such code as it lacks knowledge about the application logic.
In this talk, we present Query By Synthesis (QBS), a system that automatically identifies imperative program fragments and uses program synthesis to convert functionality written as imperative code into relational queries to be executed in the database. Using real-world examples, we show that QBS can convert a variety of imperative constructs into relational queries, and can improve application performance by orders of magnitude.