Lune

ASE2022顶会

reformulator: Automated Refactoring of the N+1 Problem in Database-Backed Applications

Alexi Turcotte, Mark W. Aldrich, Frank Tip

摘要

An Object-Relational Mapping (ORM) provides an object-oriented interface to a database and facilitates the development of databasebacked applications. In an ORM, programmers do not need to write queries in a separate query language such as SQL, they instead write ordinary method calls that are mapped by the ORM to database queries. This added layer of abstraction hides the significant performance cost of database operations, and misuse of ORMs can lead to far more queries being generated than necessary. Of particular concern is the infamous "N+1 problem", where an initial query yields N results that are used to issue N subsequent queries. This anti-pattern is prevalent in applications that use ORMs, as it is natural to iterate over collections in object-oriented languages. However, iterating over data that originates from a database and calling an ORM method in each iteration may result in suboptimal performance. In such cases, it is often possible to reduce the number of round-trips to the database by issuing a single, larger query that fetches all desired results at once. We propose an approach for automatically refactoring applications that use ORMs to eliminate instances of the "N+1 problem", which relies on static analysis to detect data flow between ORM API calls. We implement this approach in a tool called reformulator, targeting the Sequelize ORM in JavaScript, and evaluate it on 8 JavaScript projects. We found 44 N+1 query pairs in these projects, and reformulator refactored all of them successfully, resulting in improved performance (up to 7.67x) while preserving program behavior. Further experiments demonstrate that the relative performance improvements grew as the database size was increased (up to 38.58x), and show that front-end page load times were also improved.

问 Lune

几分钟读透这篇 Paper,不用再花一下午。

Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。

已有 1 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。

可以从这些问题问起

Lune 可以查阅

全文 · 引用它的顶会 Paper · 相关的 Paper

获取答案

免费开始,无需绑卡

脉络

  • Increasing the Responsiveness of Web Applications by Introducing Lazy Loading 引用了 Detecting Node.js prototype pollution vulnerabilities via object lookup analysis
  • Increasing the Responsiveness of Web Applications by Introducing Lazy Loading 引用了 Automatic migration from synchronous to asynchronous JavaScript APIs
它引用的引用它的从左到右按年份排列,引用越多,位置越高。

引用它的顶会 Paper1

  1. Increasing the Responsiveness of Web Applications by Introducing Lazy LoadingAlexi Turcotte, Satyajit Gokhale, Frank TipASE 2023 · 3 次引用

它引用的 Paper3

  1. Detecting Node.js prototype pollution vulnerabilities via object lookup analysisSong Li, Mingqing Kang, Jianwei Hou, Yinzhi CaoFSE 2021 · 49 次引用
  2. Automatic migration from synchronous to asynchronous JavaScript APIsSatyajit Gokhale, Alexi Turcotte, Frank TipOOPSLA 2021 · 23 次引用
  3. Repairing serializability bugs in distributed database programs via automated schema refactoringKia Rahmani, Kartik Nagar, Benjamin Delaware, Suresh JagannathanPLDI 2021 · 4 次引用

相关 Paper

  1. Unlocking Optimal ORM Database Designs: Accelerated Tradeoff Analysis with TransformersMd Rashedul Hasan, Mohammad Rashedul Hasan, Hamid BagheriFSE 2025
  2. Verification of ORM-based Controllers by Summary InferenceGeetam Chawla, Navneet Aman, Raghavan Komondoor, Ashish Bokil 等ICSE 2022 · 2 次引用
  3. DrAsync: Identifying and Visualizing Anti-Patterns in Asynchronous JavaScriptAlexi Turcotte, Michael D. Shah, Mark W. Aldrich, Frank TipICSE 2022 · 5 次引用
  4. SQLCheck: Automated Detection and Diagnosis of SQL Anti-PatternsPrashanth Dintyala, Arpit Narechania, Joy ArulrajSIGMOD 2020 · 26 次引用
  5. Database Deadlock Diagnosis for Large-Scale ORM-Based Web ApplicationsZhiyuan Dong, Zhaoguo Wang, Chuanwei Yi, Xian Xu 等ICDE 2023 · 7 次引用
黄昏的海面,两侧是细线勾勒的悬崖