embedding
embedding · HNSW vector similarity search extension for PostgreSQL real[] embeddings.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100981 | embedding | embedding | 0.3.6 | RAG | Apache-2.0 | C |
PostgreSQL · 12, 13, 14, 15, 16
Usage
Sources:
embedding version 0.3.6 stores vectors as real[] and adds an HNSW access method for approximate nearest-neighbor search. Operators include Euclidean distance <->, cosine distance <=>, and Manhattan distance <~>.
Example
The upstream repository is archived and explicitly says pg_embedding is deprecated, with migration to pgvector strongly recommended. Keep vector dimensions consistent; dims is mandatory for an index and must equal the array element count.
Use dense, NULL-free arrays with finite coordinates. The C distance path reads the raw real[] payload without checking for null elements, and cosine distance divides by both vector norms, so a zero vector produces an undefined/NaN result. Validate HNSW recall and tune its build/query parameters against representative data. Use this only to support an existing deployment while planning migration, not for a new system.