Index options

m
number
default: "16"

The number of bi-directional links created for every new element during construction. Reasonable range for m is 2-100. Higher m work better on datasets with high intrinsic dimensionality and/or high recall, while low m work better for datasets with low intrinsic dimensionality and/or low recalls.

Maximum allowed value for m is 128

ef_construction
number
default: "128"

The size of the dynamic list for the nearest neighbors (used during the index construction). Higher ef_construction leads to better index quality, but reduces indexing speed.

Maximum allowed value for ef_construction is 400

ef
number
default: "64"

The size of the dynamic list for the nearest neighbors (used during search). Higher ef leads to more accurate but slower search. (this parameter is also controlled via seesion based hnsw.ef variable)

Maximum allowed value for ef is 400

This parameter is also controlled via session based hnsw.ef variable, which has precedence over this parameter sql SET hnsw.ef=128

dim
number

Vector dimensions that will be stored in the table. If not specified it will try to be inferred from the existing data.

Maximum allowed dimensions for now is 2000

_experimental_index_path
string

Path to index file created via Lantern CLI

In order for the index file to function properly, it should be present in the server where the database is running and accessible to the user running the database.

Index parameters

hnsw.init_k
string
default: "10"

Number of items you are expecting from index to return. This is session based variable.

It is important to set this value according the LIMIT in your query or the search performance will be decreased. For example if you do a query like this

SELECT * FROM lantern_demo WHERE v <-> ARRAY[1,1,1] LIMIT 100;

You should set the hnsw.init_k to 100. So the query will become like this

SET hnsw.init_k = 100;
SELECT * FROM lantern_demo WHERE v <-> ARRAY[1,1,1] LIMIT 100;

Maximum allowed value for hnsw.init_k is 1000

hnsw.ef
string
default: "64"

This is session based variable which will controll the ef parameter of your index.

This variable has priority over the ef option specified in the index creation.

If you create an index like this

CREATE INDEX ON lantern_demo USING hnsw(v) WITH (m=4, ef_construction=8, ef=16);

And do a query like this

SET hnsw.ef = 128;
SELECT * FROM lantern_demo WHERE v <-> ARRAY[1,1,1];

Your query will run with ef parameter set to 128 instead of 16.

Maximum allowed value for hnsw.ef is 400