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.
翻译:向量相似性搜索在数据科学管道中日益重要,尤其在检索增强生成(RAG)中,它通过高效检索相关外部知识来增强大语言模型推理。随着RAG结合表格增强生成以整合结构化数据,融合表格与向量搜索的工作负载日益普遍。然而,因向量搜索组件的基数估计不准确导致查询计划次优,高效执行此类查询仍具挑战。本文提出Exqutor——一种面向向量增强分析查询的扩展查询优化器。Exqutor是可插拔基数估计框架,利用精确基数查询优化技术在向量索引(如HNSW、IVF)可用时提升估计精度。缺乏此类索引时,我们采用自适应采样量调整的采样方法,动态调节样本量以平衡估计精度与采样开销,从而使Exqutor在最小化计算成本的同时高效近似向量搜索基数。我们将该框架集成至pgvector、VBASE和DuckDB中,在向量增强分析查询上实现了高达四个数量级的性能提升。