Developing high-performance applications that interact with databases is a difficult task, as developers need to understand both the details of the language in which their applications are written in, and also the intricacies of the relational model. One popular solution to this problem is the use of object-relational mapping (ORM) libraries that provide transparent access to the database using the same language that the application is written in. Unfortunately, using such frameworks can easily lead to applications with poor performance because developers often end up implementing relational operations in application code, and doing so usually does not take advantage of the optimized implementations of relational operations, efficient query plans, or push down of predicates that database systems provide. In this paper we present QBS, an algorithm that automatically identifies fragments of application logic that can be pushed into SQL queries. The QBS algorithm works by automatically synthesizing invariants and postconditions for the original code fragment. The postconditions and invariants are expressed using a theory of ordered relations that allows us to reason precisely about the contents and order of the records produced even by complex code fragments that compute joins and aggregates. The theory is close in expressiveness to SQL, so the synthesized postconditions can be readily translated to SQL queries. Using 40 code fragments extracted from over 120k lines of open-source code written using the Java Hibernate ORM, we demonstrate that our approach can convert a variety of imperative constructs into relational specifications.
翻译:开发与数据库互动的高性能应用程序是一项困难的任务,因为开发者需要了解其应用程序在其中写成的语言的详细细节,以及关系模型的复杂性。这个问题的一个普遍解决办法是使用对象关系映射(ORM)图书馆,这些图书馆使用与应用程序所写语言相同的语言透明地访问数据库。不幸的是,使用这种框架很容易导致应用性能差,因为开发者往往在应用代码中执行关系操作,而这样做通常不会利用关系操作的最佳实施、高效查询计划或数据库系统提供的上游数据。在这个文件中,我们介绍了QBS,一种自动识别应用逻辑碎片的算法,可以将其推入SQL查询中。QBS算法的工作是自动合成变量和原代码碎片的后缀。根据一种有秩序的关系的理论来表达后缀和变异性,使得我们能够精确地了解即使由复杂代码碎片生成的内容和顺序,从而能够将精度合并成40号,并且能够将S-BS-L的逻辑转换成一个快速的解算法。可以将我们的代码转换成一个快速的S-L的解算法,可以将我们快速地转换成一个快速的解算。