arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2312.00638cs.DB
收藏

如果一条 SQL 语句返回一个数据库会怎样?

What if an SQL Statement Returned a Database?

Joris Nix, Jens Dittrich

AI总结:

本文提出用 RESULTDB 关键字扩展 SQL 的 SELECT 子句,使其返回结果数据库而非单表,从而避免连接非规范化,并改善查询性能、结果传输效率及优化器设计。

摘要:

每条 SQL 语句都被限制为返回单个、可能是非规范化的表。这一设计决策产生了深远的影响:(1)对数据库用户而言,表现为查询性能缓慢、查询结果传输时间长、SQL 在 Web 应用和对象关系映射器中的可用性问题。此外,(2)对数据库架构师而言,在设计查询优化器时,它会导致逻辑(代数)连接枚举开销、中间结果物化的内存消耗以及物理算子选择开销。因此,基本上整个查询优化栈都是由这一设计决策塑造的。在本文中,我们主张应当取消单表限制。我们通过关键字 'RESULTDB' 扩展 SQL 的 SELECT 子句,以支持返回结果数据库。我们的方法具有清晰的语义,即我们扩展后的 SQL 返回所有表的子集,其中只包含那些属于传统(单表)查询结果集的元组,但不通过连接执行任何非规范化。我们的 SQL 扩展是向下兼容的。此外,我们讨论了该方法出人意料地长的一系列好处。首先,对数据库用户而言:应用代码更简单、更易读,查询性能更好,查询结果更小,查询结果传输时间更短。其次,对数据库架构师而言,我们展示了如何利用现有的闭源系统,以及如何修改开源数据库系统以支持我们的特性。我们提出了若干算法,将我们的特性集成到闭源和开源数据库系统中。我们给出了一项初步实验研究,结果令人鼓舞。

英文摘要:

Every SQL statement is limited to return a single, possibly denormalized, table. This design decision has far reaching consequences. (1.) for databases users in terms of slow query performance, long query result transfer times, usability-issues of SQL in web applications and object-relational mappers. In addition, (2.) for database architects it has consequences when designing query optimizers leading to logical (algebraic) join enumeration effort, memory consumption for intermediate result materialization, and physical operator selection effort. So basically, the entire query optimization stack is shaped by that design decision. In this paper, we argue that the single-table limitation should be dropped. We extend the SELECT-clause of SQL by a keyword 'RESULTDB' to support returning a result database. Our approach has clear semantics, i.e. our extended SQL returns subsets of all tables with only those tuples that would be part of the traditional (single-table) query result set, however without performing any denormalization through joins. Our SQL-extension is downward compatible. Moreover, we discuss the surprisingly long list of benefits of our approach. First, for database users: far simpler and more readable application code, better query performance, smaller query results, better query result transfer times. Second, for database architects, we present how to leverage existing closed source systems as well as change open source database systems to support our feature. We propose a couple of algorithms to integrate our feature into both closed-source as well as open source database systems. We present an initial experimental study with promising results.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑