Posted in

使用这个新的开源扩展,让 Pgvector 比 Pinecone 更快,成本降低 75%_AI阅读总结 — 包阅AI

包阅导读总结

1.

关键词:`PostgreSQL`、`pgvectorscale`、`Pinecone`、`向量数据库`、`性能优化`

2.

总结:本文主要介绍了开源扩展 pgvectorscale 能让 PostgreSQL 在向量存储和搜索方面比 Pinecone 性能更优且成本更低。通过对比测试,展示了其在性能和成本上的优势,强调了 PostgreSQL 作为 AI 应用基础的潜力。

3.

主要内容:

– 开发者常纠结通用数据库与专用向量数据库,专用向量库如 Pinecone 以往性能占优。

– Timescale 团队开发 pgvectorscale 提升 PostgreSQL 性能,挑战传统观念。

– 它是开源扩展,基于 pgvector,用 Rust 编写,丰富了 PostgreSQL 的 AI 生态。

– 有两大创新:StreamingDiskANN 向量搜索索引和 Statistical Binary Quantization 技术。

– 与 Pinecone 对比测试,PostgreSQL 结合 pgvector 和 pgvectorscale 表现出色,成本低得多。

– 强调 PostgreSQL 是 AI 应用的理想基础,相关扩展降低了采用和扩展的门槛。

– 相关开源扩展可在 Github 安装,也可在 Timescale 云平台获取。

思维导图:

文章地址:https://thenewstack.io/make-pgvector-faster-than-pinecone-and-75-cheaper-with-this-new-open-source-extension/

文章来源:thenewstack.io

作者:Avthar Sewrathan

发布时间:2024/7/12 14:59

语言:英文

总字数:1139字

预计阅读时间:5分钟

评分:90分

标签:AI 应用,PostgreSQL,Pgvector,Pgvectorscale,Pinecone


以下为原文内容

本内容来源于用户推荐转载,旨在分享知识与观点,如有侵权请联系删除 联系邮箱 media@ilingban.com

A common question I hear from developers building AI applications is, “Do I need a standalone vector database, or can I just use a general-purpose database I already have and know?”

And while general-purpose databases like PostgreSQL have gained popularity for vector storage and search thanks to their familiarity and extensions like pgvector, the one argument for opting to use a dedicated vector database, like Pinecone, has been the promise of greater performance. The reasoning goes like this: dedicated vector databases have purpose-built data structures and algorithms for storing and searching large volumes of vector data, thus offering better performance and scalability than general-purpose databases with added vector support.

My team at Timescale, the PostgreSQL cloud database company, built pgvectorscale to make PostgreSQL a better database for AI and challenge the notion that PostgreSQL and pgvector are not performant for workloads. Pgvectorscale brings specialized data structures and algorithms for large-scale vector search and storage to PostgreSQL as an extension, helping deliver comparable and often superior performance than specialized vector databases like Pinecone.

Pgvectorscale: High-Performance, Cost-Efficient Scaling for Large Vector Workloads on PostgreSQL

Pgvectorscale is an open source PostgreSQL extension that builds on pgvector, enabling greater performance and scalability (keep reading for the actual numbers). Using pgvector and pgvectorscale, developers can build more scalable AI applications, benefiting from higher-performance embedding search and cost-efficient storage.

Licensed under the open source PostgreSQL License, pgvectorscale complements pgvector by leveraging the pgvector data type and distance functions, further enriching the PostgreSQL ecosystem for building AI applications. While pgvector is written in C, the pgvectorscale extension is written in Rust, giving the community a new avenue to contribute to vector support in PostgreSQL.

Pgvectorscale builds on pgvector with two key innovations:

StreamingDiskANN vector search index: StreamingDiskANN overcomes limitations of in-memory indexes like HNSW (hierarchical navigable small world) by storing part of the index on disk, making it more cost-efficient to run and scale as vector workloads grow. Inspired by Microsoft research and then improved by Timescale AI researchers, pgvectorscale’s StreamingDiskANN index optimizes pgvector data for low-latency, high throughput search without sacrificing high accuracy. The ability to store the index on disk vastly decreases the cost of storing and searching over large amounts of vectors since SSDs are much cheaper than RAM.

Statistical Binary Quantization (SBQ): Developed by researchers at Timescale, this technique improves standard binary quantization techniques by improving accuracy when using quantization to reduce the space needed for vector storage.

Pgvector vs. Pinecone: Performance Impact of pgvectorscale

Let’s briefly unpack the claim that pgvectorscale helps PostgreSQL get comparable and often superior performance than specialized vector databases like Pinecone.

To test the performance impact of pgvectorscale, we compared the performance of PostgreSQL with pgvector and pgvectorscale against Pinecone, widely regarded as the market leader for specialized vector databases, on a benchmark using a dataset of 50 million Cohere embeddings (of 768 dimensions each).

PostgreSQL with pgvector and pgvectorscale outperformed Pinecone’s storage-optimized index (s1) with 28x lower p95 latency and 16x higher query throughput for approximate nearest neighbor queries at 99% recall.

Furthermore, PostgreSQL with pgvectorscale achieves 1.4x lower p95 latency and 1.5x higher query throughput than Pinecone’s performance-optimized index (p2) at 90% recall on the same dataset. The p2 pod index is what Pinecone recommends if you want the best possible performance, and to our surprise pgvectorscale still helped PostgreSQL outperform it!

This impressive performance, combined with the trusted reliability and continuous evolution of PostgreSQL, makes it clear: building on PostgreSQL with pgvector and pgvectorscale is the intelligent choice for developers aiming to create high-performing, scalable AI applications.

The cost benefits are equally compelling. Self-hosting PostgreSQL with pgvector and pgvectorscale is 75-79% cheaper than Pinecone. Self-hosting PostgreSQL costs approximately $835 per month on AWS EC2, compared to Pinecone’s $3,241 per month for the storage-optimized index (s1) and $3,889 per month for the performance-optimized index (p2).

This result disproves the claims that PostgreSQL and pgvector are easy to start with but not scalable or performant for AI applications. With pgvectorscale, developers building GenAI applications can enjoy purpose-built performance for vector search without giving up the benefits of a fully featured PostgreSQL database and ecosystem.

And those benefits are numerous. Choosing a standalone vector database would mean you lose out on the full spectrum of data types, transactional semantics, and operational features that exist in a general-purpose database and are often necessary for deploying production apps. PostgreSQL also offers abundant tooling and a rich ecosystem — think pg_stat_statements for query statistics, EXPLAIN plans for debugging slow queries, and the numerous connectors, libraries, and drivers for every other technology in your AI data stack.

If you’d like to learn more about pgvectorscale’s performance, here’s a technical explanation of how StreamingDiskANN and Statistical Binary Quantization work. There’s also more detail about the benchmarking methodology and results in this pgvector vs. Pinecone comparison blog post.

PostgreSQL as the Foundation for AI Applications

Databases are critical to building AI applications, and I think all applications will be AI applications in the future. The rise of AI applications that leverage LLMs also means that developers demand more from their databases. The good news is that PostgreSQL is evolving to meet changing developer needs, thanks to its rich ecosystem and community.

I believe that PostgreSQL — with its rich ecosystem, multiple data type support, and battle-tested reliability — is the bedrock for the future of data. I’ve heard this concisely expressed as “PostgreSQL for Everything.” And in the future, everything will be infused with AI.

At Timescale, we believe PostgreSQL is the bedrock of the future of data. The strength of the PostgreSQL ecosystem is what makes it the most loved database for professional developers.

According to the 2023 Stack Overflow Developer Survey, PostgreSQL is the most popular database choice among professional developers and developers in general.

I’d argue that PostgreSQL is the ideal foundation for the future of AI applications. Extensions like pgvector, pgvectorscale, and pgai lower the barriers to adopting and scaling PostgreSQL for AI applications — whether they be search, RAG, or Agents — by removing the need to adopt a separate vector database and simplifying data architectures.

As the PostgreSQL for AI ecosystem continues to develop, I hope that even more developers can trade complex, brittle data architectures (juggling multiple databases) for the rock-solid foundation, versatile extensions, and straightforward simplicity of PostgreSQL in their AI data stack.

Build Your AI Applications With PostgreSQL Today

Pgvector, pgvectorscale, and pgai are all open source under the PostgreSQL License and are available for you to use in your AI projects today.

You can find installation instructions on Github (linked above). And if you’re looking for a managed database, you can access all three extensions on Timescale’s cloud PostgreSQL platform.

YOUTUBE.COM/THENEWSTACK

Tech moves fast, don’t miss an episode. Subscribe to our YouTubechannel to stream all our podcasts, interviews, demos, and more.

GroupCreated with Sketch.