Analytical database systems serve as foundational infrastructure for knowledge discovery across many domains. Day after day, researchers, practitioners, and increasingly AI-driven agents issue analytical queries, inspect their results, and refine their inquiries. An analytical database system thus receives and processes diverse analytical queries that arrive over time and execute concurrently. Such workloads can create redundant execution work across independently issued queries. Exploiting this overlap to optimize query processing as a whole is a critical technical challenge. This paper presents GraftDB, a multi-query execution engine that dynamically folds a later-arriving query into a running execution, reusing previously performed work and sharing subsequently performed work. GraftDB achieves dynamic folding with state-centric execution, which treats operator state accumulated during execution not as owned by a single query, but as shared state that any compatible query can observe or contribute to. Each query observes shared state through a per-query state lens, which lets the query observe that state only after the relevant input has been incorporated and receive only rows or state fragments valid under the query's semantics. For an arriving query, query grafting identifies operator state that already satisfies part of the query's requirements and work that can still be shared to satisfy the rest. Together, these mechanisms let GraftDB share work across overlapping analytical queries and reduce redundant execution work. Experiments using TPC-H-derived instances of dynamic concurrent workloads show that GraftDB achieves up to 2.17 times higher throughput than a same-engine isolated-execution baseline. Under overloaded open-loop arrivals, GraftDB reduces P95 response time to as low as 0.17 times the same baseline's P95 response time.
翻译:分析型数据库系统是跨领域知识发现的基础设施。研究者、实践者以及日益增多的AI驱动代理日复一日地提交分析查询、检查结果并完善其问题。分析型数据库系统因此接收并处理随时间到达且并发执行的各种分析查询。此类工作负载可能在独立提交的查询之间产生冗余执行工作,利用这种重叠来整体优化查询处理是一项关键技术挑战。本文提出GraftDB,一种多查询执行引擎,它能将后到达的查询动态折叠到正在执行的查询中,重用此前已完成的工作并共享后续执行的工作。GraftDB通过以状态为核心的执行实现动态折叠,该方法将执行过程中累积的操作符状态视为共享状态(而非由单一查询所有),任何兼容的查询均可观察或贡献该状态。每个查询通过按查询的状态透镜观察共享状态,使得查询仅在相关输入被合并后才能观察该状态,并仅接收在查询语义下有效的行或状态片段。对于新到达的查询,查询嫁接机制可识别已满足查询部分需求的操作符状态,以及仍可共享以满足其余需求的执行工作。这些机制共同使GraftDB能够在重叠分析查询间共享工作并减少冗余执行。使用TPC-H衍生实例的动态并发工作负载实验表明,GraftDB的吞吐量比同引擎隔离执行基线提升高达2.17倍。在过载的开环到达场景下,GraftDB将P95响应时间降至同一基线的0.17倍。