配置项 | 说明 |
数据库 | RDS PostgreSQL 17 |
pgvector | 0.8.0 |
实例规格 | 16vCPU / 64GB |
客户端 | 4vCPU / 8GB(同 VPC) |
测试工具 | |
压测模式 | 单线程 |
召回口径 | Recall@100 |
数据集 | 维度 | 向量数 | 距离类型 | 典型场景 |
dbpedia-openai-1M | 1536 | 1,000,000 | Cosine | OpenAI /大模型 Embedding |
NYTimes-256 | 256 | 290,000 | Cosine | 文本相似度检索 |
git clone https://github.com/erikbern/ann-benchmarks.gitcd ann-benchmarkspip install -r requirements.txt
ann_benchmarks/algorithms/pgvector/module.py,添加连接信息:import osos.environ['ANN_BENCHMARKS_PG_USER'] = '<用户名>'os.environ['ANN_BENCHMARKS_PG_PASSWORD'] = '<密码>'os.environ['ANN_BENCHMARKS_PG_DBNAME'] = '<数据库名>'os.environ['ANN_BENCHMARKS_PG_HOST'] = '<实例内网地址>'os.environ['ANN_BENCHMARKS_PG_PORT'] = '5432'os.environ['ANN_BENCHMARKS_PG_START_SERVICE'] = 'false'
ann_benchmarks/algorithms/pgvector/config.yml:float:any:- base_args: ['@metric']constructor: PGVectordisabled: falsedocker_tag: ann-benchmarks-pgvectormodule: ann_benchmarks.algorithms.pgvectorname: pgvectorrun_groups:M-16(200):arg_groups: [{M: 16, efConstruction: 200}]args: {}query_args: [[10, 20, 40, 80, 120, 200, 400, 800]]M-24(200):arg_groups: [{M: 24, efConstruction: 200}]args: {}query_args: [[10, 20, 40, 80, 120, 200, 400, 800]]M-48(256):arg_groups: [{M: 48, efConstruction: 256}]args: {}query_args: [[10, 20, 40, 80, 120, 200, 400, 800]]
python install.py --algorithm pgvector
# dbpedia-openai-1M数据集测试python run.py --dataset dbpedia-openai-1000k-angular -k 100 --algorithm pgvector --runs 1# NYTimes-256 数据集测试python run.py --dataset nytimes-256-angular -k 100 --algorithm pgvector --runs 1
# 生成可视化图表python plot.py --dataset dbpedia-openai-1000k-angular --recompute# 导出详细 CSV数据python data_export.py --out results.csv
场景 | 索引配置 | ef_search | Recall@100 | QPS | P99(ms) |
高召回 | m=24, ef_construction=200 | 120 | 99.2% | 225 | 7.2 |
超高召回 | m=48, ef_construction=256 | 120 | 99.8% | 146 | 12.3 |
场景 | 索引配置 | ef_search | Recall@100 | QPS | P99(ms) |
高召回 | m=24, ef_construction=200 | 400 | 89.0% | 101 | 12.7 |
超高召回 | m=24, ef_construction=200 | 800 | 93.9% | 52 | 23.6 |
文档反馈