Abstract
Object-relational mapping libraries are a popular way for applications to interact with databases because they provide transparent access to the database using the same language as the application. Unfortunately, using such frameworks often leads to poor performance, as modularity concerns encourage developers to implement relational operations in application code. Such application code does not take advantage of the optimized relational implementations that database systems provide, such as efficient implementations of joins or push down of selection predicates. In this paper we present QBS, a system that automatically transforms fragments of application logic into SQL queries. QBS differs from traditional compiler optimizations as it relies on synthesis technology to generate invariants and postconditions for a code fragment. The postconditions and invariants are expressed using a new theory of ordered relations that allows us to reason precisely about both the contents and order of the records produced 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 75 code fragments automatically 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 and significantly improve application performance asymptotically by orders of magnitude.
- itracker Issue Management System. http://itracker.sourceforge.net/index.html.Google Scholar
- Wilos Orchestration Software. http://www.ohloh.net/p/6390.Google Scholar
- z3 Theorem Prover. http://research.microsoft.com/en-us/um/redmond/projects/z3.Google Scholar
- S. Abiteboul, R. Hull, and V. Vianu. Foundations of Databases. Addison-Wesley, 1995. Google Scholar
Digital Library
- J. R. Allen and K. Kennedy. Automatic loop interchange. In Proc. CC, pages 233--246, 1984. Google Scholar
Digital Library
- A. Blass and Y. Gurevich. Inadequacy of computable loop invariants. ACM Trans. Comput. Log., 2(1):1--11, 2001. Google Scholar
Digital Library
- A. Cheung, O. Arden, S. Madden, and A. C. Myers. Automatic partitioning of database applications. PVLDB, 5, 2011. Google Scholar
Digital Library
- A. Cheung, A. Solar-Lezama, and S. Madden. Using program synthesis for social recommendations. In Proc. CIKM, pages 1732--1736, 2012. Google Scholar
Digital Library
- E. Cooper. The script-writer's dream: How to write great sql in your own language, and be sure it will succeed. In Proc. DBPL Workshop, pages 36--51, 2009. Google Scholar
Digital Library
- E. Cooper, S. Lindley, P. Wadler, and J. Yallop. Links: Web programming without tiers. In Proc. Int.l Symp. on Formal Methods for Components and Objects, pages 266--296, 2006. Google Scholar
Digital Library
- D. Déharbe, P. Fontaine, S. Merz, and B. W. Paleo. Exploiting symmetry in smt problems. In Proc. Int.l Conf. on Automated Deduction, pages 222--236, 2011. Google Scholar
Digital Library
- E. W. Dijkstra. Guarded commands, nondeterminacy and formal derivation of programs. Commun. ACM, 18(8):453--457, 1975. Google Scholar
Digital Library
- M. D. Ernst, J. Cockrell,W. G. Griswold, and D. Notkin. Dynamically discovering likely program invariants to support program evolution. In Proc. ICSE, pages 213--224, 1999. Google Scholar
Digital Library
- C. Flanagan and S. Qadeer. Predicate abstraction for software verification. In Proc. POPL, pages 191--202, 2002. Google Scholar
Digital Library
- P. Godefroid and A. Taly. Automated synthesis of symbolic instruction encodings from I/O samples. In Proc. PLDI, pages 441--452, 2012. Google Scholar
Digital Library
- D. Gries. The Science of Programming. Springer, 1987. Google Scholar
Digital Library
- T. Grust, M. Mayr, J. Rittinger, and T. Schreiber. FERRY: databasesupported program execution. In Proc. SIGMOD, pages 1063--1066, 2009. Google Scholar
Digital Library
- A. Gupta and A. Rybalchenko. Invgen: An efficient invariant generator. In Proc. CAV, pages 634--640, 2009. Google Scholar
Digital Library
- C. A. R. Hoare. An axiomatic basis for computer programming. Commun. ACM, 12(10):576--580, 1969. Google Scholar
Digital Library
- M.-Y. Iu, E. Cecchet, and W. Zwaenepoel. Jreq: Database queries in imperative languages. In Proc. CC, pages 84--103, 2010. Google Scholar
Digital Library
- M.-Y. Iu and W. Zwaenepoel. HadoopToSQL: a mapreduce query optimizer. In Proc. EuroSys, pages 251--264, 2010. Google Scholar
Digital Library
- D. Jackson. Alloy: a lightweight object modelling notation. ACM Trans. Softw. Eng. Methodol., 11(2):256--290, 2002. Google Scholar
Digital Library
- E. Meijer, B. Beckman, and G. Bierman. LINQ: Reconciling objects, relations and XML in the .NET framework. In Proc. SIGMOD, pages 706--706, 2006. Google Scholar
Digital Library
- W. Ng. An extension of the relational data model to incorporate ordered domains. Trans. Database Syst., 26(3):344--383, Sept. 2001. Google Scholar
Digital Library
- N. Nystrom, M. R. Clarkson, and A. C. Myers. Polyglot: An extensible compiler framework for Java. In Proc. CC, pages 138--152, 2003. Google Scholar
Digital Library
- K. Ramachandra, R. Guravannavar, and S. Sudarshan. Program analysis and transformation for holistic optimization of database applications. In Proc. SOAP Workshop, pages 39--44, 2012. Google Scholar
Digital Library
- M. Sagiv, T. Reps, and R. Wilhelm. Parametric shape analysis via 3-valued logic. In Proc. POPL, pages 105--118, 1999. Google Scholar
Digital Library
- J. W. Schmidt and F. Matthes. The DBPL project: Advances in modular database programming. Inf. Syst., 19(2):121--140, 1994. Google Scholar
Digital Library
- R. Singh and A. Solar-Lezama. Synthesizing data structure manipulations from storyboards. In Proc. FSE, pages 289--299, 2011 Google Scholar
Digital Library
- A. Solar-Lezama, L. Tancau, R. Bodík, S. Seshia, and V. Saraswat. Combinatorial sketching for finite programs. In Proc. ASPLOS, pages 404--415, 2006. Google Scholar
Digital Library
- S. Srivastava and S. Gulwani. Program verification using templates over predicate abstraction. In Proc. PLDI, pages 223--234, 2009. Google Scholar
Digital Library
- S. Srivastava, S. Gulwani, S. Chaudhuri, and J. S. Foster. Path-based inductive synthesis for program inversion. In Proc. PLDI, pages 492--503, 2011. Google Scholar
Digital Library
- Z. Tatlock and S. Lerner. Bringing extensibility to verified compilers. In Proc. PLDI, pages 111--121, 2010. Google Scholar
Digital Library
- E. Torlak and D. Jackson. Kodkod: a relational model finder. In Proc. TACAS, pages 632--647, 2007. Google Scholar
Digital Library
- O. Tripp, M. Pistoia, S. J. Fink, M. Sridharan, and O. Weisman. Taj: effective taint analysis of web applications. In Proc. PLDI, pages 87--97, 2009. Google Scholar
Digital Library
- J. Whaley and M. Rinard. Compositional pointer and escape analysis for java programs. In Proc. OOPSLA, pages 187--206, 1999. Google Scholar
Digital Library
- B. Wiedermann and W. R. Cook. Extracting queries by static analysis of transparent persistence. In Proc. POPL, pages 199--210, 2007. Google Scholar
Digital Library
- B. Wiedermann, A. Ibrahim, and W. R. Cook. Interprocedural query extraction for transparent persistence. In Proc. OOPSLA, pages 19--36, 2008. Google Scholar
Digital Library
- L. Wong. Kleisli, a functional query system. J. Funct. Program., 10(1):19--56, 2000. Google Scholar
Digital Library
- Y. Xie and A. Aiken. Scalable error detection using boolean satisfiability. In Proc. POPL, pages 351--363, 2005. Google Scholar
Digital Library
Index Terms
Optimizing database-backed applications with query synthesis
Recommendations
Optimizing database-backed applications with query synthesis
PLDI '13: Proceedings of the 34th ACM SIGPLAN Conference on Programming Language Design and ImplementationObject-relational mapping libraries are a popular way for applications to interact with databases because they provide transparent access to the database using the same language as the application. Unfortunately, using such frameworks often leads to ...
Optimizing synthesis with metasketches
POPL '16Many advanced programming tools---for both end-users and expert developers---rely on program synthesis to automatically generate implementations from high-level specifications. These tools often need to employ tricky, custom-built synthesis algorithms ...
Optimizing synthesis with metasketches
POPL '16: Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming LanguagesMany advanced programming tools---for both end-users and expert developers---rely on program synthesis to automatically generate implementations from high-level specifications. These tools often need to employ tricky, custom-built synthesis algorithms ...







Comments