对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

额外性能建议

本页提供了有关提高MongoDB Vector Search 搜索查询性能的其他建议。

当向量数据保存在内存中时,分层可导航小世界可以高效运行。您必须确保数据节点有足够的RAM来保存向量数据和索引。我们建议部署单独的搜索节点以实现工作负载隔离性,而不进行数据隔离性,这样可以更有效地为向量搜索使用案例使用内存。

嵌入模型
向量维度
空间要求

Voyage AI voyage_3_large

2048

8kb(适用于 float)
2.14kb(适用于 int8)
0.334kb(适用于 int1)

OpenAI text-embedding-ada-002

1536

6 kb

Google text-embedding-gecko

768

3 kb

Cohere embed-english-v3.0

1024

4kb(适用于 float)
1.07kb(适用于 int8)
0.167kb(适用于 int1)

BinData quantized vectors. To learn more, see Ingest Quantized Vectors.

MongoDB 向量搜索消耗的 CPU、内存和磁盘资源量取决于多个因素,包括索引大小和查询条件。请务必监控您的环境,以了解向量搜索的运行状况和性能,并确认有足够的基础架构容量并识别任何异常情况。

使用以下指标观察并提高MongoDB Vector Search 搜索索引和查询的性能:

监控MongoDB Vector Search 搜索索引使用的RAM总量。足够的RAM对于MongoDB向量搜索查询性能至关重要,因为进入磁盘的查询性能要低得多。确保整个索引能够容纳在内存中。

Ensure that available System Memory is always greater than used System Memory. If the index is not frequently queried, not all of the index might be in memory. Therefore, leverage the System Memory metric in conjunction with the Index Size metric to optimize provisioning.

如果向量索引大小超过 3 GB,我们建议进行向量量化,即仅在内存中存储索引的 4%,而不是完整索引。

监控磁盘上所有索引的总大小(以字节为单位)。这是确保您准确确定RAM要求的必要条件。

Verify the search Index Size on disk metric to see what the full index size would be if 100% of the vector is stored in memory, and ensure that it is less than the system memory available.

监控所选示例周期内进程每秒的平均页面错误率。Page Faults 指标表示搜索查询写入磁盘的频率,这表明内存不适合完整索引。

该指标必须尽可能接近于零。如果始终出现页面错误,请考虑扩展集群层以预配足够的RAM。

当您在不使用专用搜索节点的情况下执行向量搜索时,您的查询最初会在遍历 Hierarchical Navigable Small Worlds图表时在磁盘上执行随机查找,并将向量值读入内存。使用搜索节点时,这种缓存预热通常仅在索引重建事件发生,通常是在计划的维护窗口期间。

向量嵌入在索引期间会消耗计算资源。精确最近邻 (ENN)对大型数据集的查询会消耗 CPU 资源。因此,同时进行索引和查询可能会导致资源瓶颈。为防止 CPU 瓶颈,当查询运行时,避免对向量进行索引。执行初始同步时,请确保搜索节点 CPU 使用率降至 0% 左右,这表明段已合并并刷新到磁盘,然后再发出测试查询。

Monitor the Search Normalized Process CPU metric during indexing operations, as heavy indexing will show elevated CPU usage. This metric shows the CPU usage as a percentage normalized against the number of available CPU cores, which enables you to assess the resource saturation relative to your cluster's capacity. After vector embeddings have been indexed, wait for the CPU usage to return close to 0% as segment merging and flushing complete.