Top
Enterprise Postgres 17 SP1 Knowledge DataManagement FeatureUser's Guide

2.4 Performance Tuning for Similar Search of Vector Data

You can verify that indexes are being used for similar searches of vector data by checking the access plan in the EXPLAIN statement.

Example) Access Plan for Vector Similar Search

EXPLAIN SELECT * FROM items ORDER BY embedding <=> '[3,1,2]' LIMIT 5;
                                      QUERY PLAN
---------------------------------------------------------------------------------------
Limit  (cost=16.60..16.81 rows=5 width=33)
   ->  Index Scan using idx_hnsw on items  (cost=16.60..437.60 rows=10000 width=33)
         Order By: (embedding <=> '[3,1,2]'::vector)
(3 rows)

See

Each vector index has parameters for tuning. See the documentation for pgvector for details.