`pgvector` compatibility
pgvecto.rs is natively compatible with pgvector at:
pgvecto.rs is natively compatible with pgvector at:
CREATE TABLEcommands, e.g.CREATE TABLE t (val vector(3))INSERT INTOcommands, e.g.INSERT INTO t (val) VALUES ('[0.6,0.6,0.6]')
pgvecto.rs can be configured to be compatible with pgvector at:
- Index options, which allows you to create index by
USING hnsw (val vector_ip_ops) - Query options, which can be set by
SET ivfflat.probes = 10
This feature is named pgvector compatibility.
It can be enabled by SET vectors.pgvector_compatibility = on.
Index Options & Query Options
For index ivfflat and hnsw only the following options are available.
- Default value for index options is different from pgvecto.rs original, which keeps the same as in
pgvector. - Default value for query options is the same as in
pgvecto.rs.
Index options for ivfflat:
| Key | Type | Range | Default | Description |
|---|---|---|---|---|
| nlist | integer | [1, 1_000_000] |
100 |
Number of cluster units. |
Query options for ivfflat:
| Option | Type | Range nn | Default | Description |
|---|---|---|---|---|
| ivfflat.probes | integer | [1, 1_000_000] |
10 |
Number of lists to scan. |
Warning
Default value of ivfflat.probes is 10 instead of 1 from pgvector.
Index options for hnsw:
| Key | Type | Range | Default | Description |
|---|---|---|---|---|
| m | integer | [4, 128] |
16 |
Maximum degree of the node. |
| ef_construction | integer | [10, 2000] |
64 |
Search scope in building. |
Query options for hnsw:
| Option | Type | Range | Default | Description |
|---|---|---|---|---|
| hnsw.ef_search | integer | [1, 65535] |
100 |
Search scope of HNSW. |
Warning
Default value for hnsw.ef_search is 100 instead of 40 from pgvector.
Examples
It’s easy to enable pgvector compatibility and start a vector query.
Multiply types of indexes are accepted: