To Iterate Is Human, to Recurse Is Divine—Mapping Iterative Python to Recursive SQL

Tim Fischer

Datenbanksysteme für Business, Technologie und Web (BTW 2023), Student Program, Dresden, Germany, March 2023. Best Student Contribution doi:10.18420/BTW2023-73

BibTeX Citation
  author    = {Fischer, Tim},
  title     = {To Iterate Is Human, to Recurse Is Divine --- Mapping Iterative Python to Recursive SQL},
  year      = {2023},
  doi       = {10.18420/BTW2023-73},
  booktitle = {BTW 2023},
  publisher = {Gesellschaft für Informatik e.V.},
  address   = {Bonn},
  isbn      = {978-3-88579-725-8},
  pages     = {1069--1074}

Writing complex algorithms and iterative computations in SQL is difficult at best, commonly leading to code that intermingles looping control flow with database access. This yields programs with control flow that rapidly hops in and out of the database, with each roundtrip incurring significant overhead. We present the ByePy compiler, which can compile entire Python functions directly to plain recursive SQL:1999 queries. By doing so, the compilation eliminates all but a single roundtrip, leading to runtime speedups of up to an order of magnitude.