[论文解读] Pay One, Get Hundreds for Free: Reducing Cloud Costs through Shared Query Execution
本文提出一种在云数据库查询即服务系统(如 Amazon Athena 和 Google BigQuery)中,通过 SQL 层查询重写技术实现多查询共享执行的方法,将查询批量处理为单次执行,从而降低云查询成本。通过在不修改底层引擎的前提下复用数据访问,该方法实现了最高达 107 倍的成本降低和 66 倍的吞吐量提升,且由于采用按字节计价模式,成本通常与单个查询相当。
Cloud-based data analysis is nowadays common practice because of the lower system management overhead as well as the pay-as-you-go pricing model. The pricing model, however, is not always suitable for query processing as heavy use results in high costs. For example, in query-as-a-service systems, where users are charged per processed byte, collections of queries accessing the same data frequently can become expensive. The problem is compounded by the limited options for the user to optimize query execution when using declarative interfaces such as SQL. In this paper, we show how, without modifying existing systems and without the involvement of the cloud provider, it is possible to significantly reduce the overhead, and hence the cost, of query-as-a-service systems. Our approach is based on query rewriting so that multiple concurrent queries are combined into a single query. Our experiments show the aggregated amount of work done by the shared execution is smaller than in a query-at-a-time approach. Since queries are charged per byte processed, the cost of executing a group of queries is often the same as executing a single one of them. As an example, we demonstrate how the shared execution of the TPC-H benchmark is up to 100x and 16x cheaper in Amazon Athena and Google BigQuery than using a query-at-a-time approach while achieving a higher throughput.
研究动机与目标
- 降低云原生查询即服务系统中因按处理字节数计费而导致的高昂执行成本。
- 在不修改底层数据库引擎或依赖云服务提供商支持的前提下,实现显著的成本节约。
- 探索仅通过 SQL 层转换在大规模场景下实现共享查询执行的可行性与优势。
- 证明通过重写实现查询批量处理,可在现有计价模型下使额外查询的边际成本接近于零。
提出的方法
- 使用嵌套的、带注释的表示法将多个并发 SQL 查询重写为单个批量查询,以追踪每个元组属于哪个原始查询。
- 通过中间件层透明地分组并重写查询,无需用户或引擎的修改。
- 在中间结果中标注查询标识符,以在每个算子处实现选择性输出投影和共享执行。
- 构建全局逻辑执行计划作为 DAG,以最大化在不同查询之间的共享,尤其针对常见的连接和扫描操作。
- 将全局计划手动转换为树状结构计划,以避免基于代价的优化开销,重点在于物化高价值的中间结果。
- 在 Amazon Athena 和 Google BigQuery 上,使用 TPC-H 基准测试在不同批量大小和配置下评估性能与成本。
实验结果
研究问题
- RQ1在不修改引擎的前提下,共享查询执行是否能显著降低无服务器、基于 SQL 的云查询即服务系统的查询成本?
- RQ2与引擎级修改相比,通过 SQL 层重写实现查询批量处理,能实现多大程度的成本节约?
- RQ3当查询访问重叠但不完全相同的数据时,共享执行对吞吐量和执行时间有何影响?
- RQ4物化公共中间结果的代价与由此带来的成本和性能收益之间存在何种权衡?
- RQ5与按类型分组的执行方式相比,单一全局执行计划在成本和吞吐量方面是否更具优势?
主要发现
- 在 Amazon Athena 中,使用共享执行将 128 个 TPC-H Query 6 实例的执行成本从 $3.417 降低至 $0.028,实现 122 倍的成本降低和 66 倍的吞吐量提升。
- 在 Google BigQuery 中,同一工作负载在排除 Query 10 的情况下,成本降低 16 倍(从 $16.07 降至 $0.088),吞吐量提升 10 倍,总成本节省达 128 倍。
- 在 BigQuery 中,全局共享计划相比独立执行,实现了 5 倍的吞吐量提升和 9.7 倍的成本降低,其中 21% 的执行时间用于物化共享中间结果。
- 即使存在物化开销,由于采用按字节计价模式,随着批量大小增加,共享执行的成本仍基本保持平稳,使额外查询近乎免费。
- 在排除不可优化查询的情况下,该方法在 Amazon Athena 中实现最高 107 倍的成本降低,在 BigQuery 中实现最高 128 倍的成本降低,充分展示了 SQL 层重写在成本优化方面的潜力。
- 该方法在处理复杂且不完全相同的查询时依然有效,通过利用查询特定的注释和选择性结果投影实现。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。