🤖 AI Summary
Traditional query optimization assumes algebraically equivalent execution plans differing only in cost; however, the integration of large language model (LLM) operators introduces a new dimension where their placement, ordering, and granularity jointly affect both execution cost and answer quality, with optimal choices requiring runtime determination. This work proposes a novel paradigm—agent-based query execution—that dynamically intertwines planning and execution through intelligent agents, and introduces EnumGRPO, an optimizer that enumerates candidate plans and leverages contextual reinforcement learning to distill reusable heuristics from quality–cost feedback. By framing agent workflow optimization as a natural extension of query optimization, the approach enables runtime adaptivity, joint optimization of quality and cost, and self-improvement. Experiments on four SWAN databases show that the method achieves 35.4% accuracy at an LLM invocation cost of $0.011 per query, reducing cost by 317× and improving accuracy by 18% over hybrid query baselines.
📝 Abstract
Classical query optimization searches over algebraically equivalent plans that differ only in cost. This assumption breaks once LLM-backed operators enter the picture: their placement, ordering, and granularity jointly determine both dollar cost and answer quality, and the right choice among the alternatives is often revealed only at runtime. We formalize this setting as agentic query execution, a query execution paradigm in which agent-based planning is interleaved with execution, and agent workflow optimization becomes the analogue of classical query optimization. We then present EnumGRPO, a self-improving optimizer for this setting. During a learning stage, EnumGRPO enumerates query plans over decisions such as execution paradigm, operator type, operator placement, selectivity scope, and projection width, then distills quality-cost feedback into reusable planning heuristics via in-context reinforcement learning. Across four databases in SWAN, EnumGRPO achieves 35.4% execution accuracy at $0.011 per query in LLM-operator cost, a ~317x cost reduction over the hybrid query baseline with an 18% relative improvement in answer accuracy.