🤖 AI Summary
In table-augmented RAG systems, suboptimal query plans arise from inaccurate cardinality estimation in vector–relational hybrid queries. To address this, we propose the first plug-and-play cardinality estimation framework tailored for vector-augmented analytical workloads. Our framework introduces a novel dual-mode mechanism that jointly leverages exact derivation—grounded in HNSW or IVF index structures—and adaptive sampling, enabling dynamic adjustment of sample size to balance estimation accuracy and computational overhead; it supports both indexed and index-free scenarios. By deeply integrating pgvector, VBASE, and DuckDB, the framework enables end-to-end generation of joint vector–relational execution plans. Experimental evaluation demonstrates up to four orders-of-magnitude improvement in end-to-end query latency, alongside substantial gains in plan quality and execution efficiency.
📝 Abstract
Vector similarity search is becoming increasingly important for data science pipelines, particularly in Retrieval-Augmented Generation (RAG), where it enhances large language model inference by enabling efficient retrieval of relevant external knowledge. As RAG expands with table-augmented generation to incorporate structured data, workloads integrating table and vector search are becoming more prevalent. However, efficiently executing such queries remains challenging due to inaccurate cardinality estimation for vector search components, leading to suboptimal query plans. In this paper, we propose Exqutor, an extended query optimizer for vector-augmented analytical queries. Exqutor is a pluggable cardinality estimation framework designed to address this issue, leveraging exact cardinality query optimization techniques to enhance estimation accuracy when vector indexes (e.g., HNSW, IVF) are available. In scenarios lacking these indexes, we employ a sampling-based approach with adaptive sampling size adjustment, dynamically tuning the sample size to balance estimation accuracy and sampling overhead. This allows Exqutor to efficiently approximate vector search cardinalities while minimizing computational costs. We integrate our framework into pgvector, VBASE, and DuckDB, demonstrating performance improvements of up to four orders of magnitude on vector-augmented analytical queries.