TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Sharding Pgvector

86 点作者 levkk大约 2 个月前

4 条评论

alexgarcia-xyz大约 2 个月前
I really dig more content about how vector databases&#x2F;tools handle problems like this!<p>In sqlite-vec, there&#x27;s only a flat brute-force index (though DiskANN&#x2F;IVF will be coming soon). But we do have a concept of partition keys[0], which allows you to &quot;internally shard&quot; the vector index based on a user_id or any other value.<p><pre><code> create virtual table vec_documents using vec0( document_id integer primary key, user_id integer partition key, contents_embedding float[1024] ) </code></pre> Then at query time, any WHERE constraints on a partition key are pushed-down, so only matching vectors are searched instead of the entire index.<p><pre><code> select document_id, user_id, distance from vec_documents where contents_embedding match :query and k = 20 and user_id = 123; -- only search documents from user 123 </code></pre> Definitely not as performant as a proper vector index, but a lot of real-world application have these natural groups anyway. Like &quot;search only English documents&quot; or &quot;search entries in this workspace only&quot;, or even &quot;search comments only from the past 30 days.&quot;<p>Internally sqlite-vec stores vectors in &quot;chunks&quot;, so when partition keys are definds, every chunk is associated with a unique combination of all partition keys. Kinda hard to describe, but if you create a vec0 virtual table and insert some values, you can inspect the internal &quot;shadow tables&quot; in the SQLite database to see how it&#x27;s all stored.<p>[0] <a href="https:&#x2F;&#x2F;alexgarcia.xyz&#x2F;sqlite-vec&#x2F;features&#x2F;vec0.html#partition-keys" rel="nofollow">https:&#x2F;&#x2F;alexgarcia.xyz&#x2F;sqlite-vec&#x2F;features&#x2F;vec0.html#partiti...</a>
评论 #43489943 未加载
jeffchuber大约 2 个月前
This will work very poorly when your data is changing because the centroids degrade and you&#x27;ll have very poor recall but likely not know it unless you are also monitoring recall.<p>I didn&#x27;t see this in the write-up, so adding it here as a common foot gun.
评论 #43485771 未加载
redskyluan大约 2 个月前
sharding is a bad solution for any databases, especially vector database. See <a href="https:&#x2F;&#x2F;milvus.io&#x2F;blog&#x2F;why-manual-sharding-is-a-bad-idea-for-vector-databases-and-how-to-fix-it.md" rel="nofollow">https:&#x2F;&#x2F;milvus.io&#x2F;blog&#x2F;why-manual-sharding-is-a-bad-idea-for...</a>
评论 #43486326 未加载
评论 #43487795 未加载
charliereese大约 2 个月前
Thanks for writing about this :)