CREATE TABLE with vectors
You are viewing an old version of this article. View
the current version here.
MariaDB has a dedicated data type VECTOR(N)
with a built-in data validation. N is the number of dimensions that all vector values in the column will have. For example,
CREATE TABLE embeddings ( doc_id BIGINT UNSIGNED PRIMARY KEY, embedding VECTOR(1536) );
To have a fast vector search one needs to index the vector column, creating a VECTOR
index:
CREATE TABLE embeddings ( doc_id BIGINT UNSIGNED PRIMARY KEY, embedding VECTOR(1536) NOT NULL, VECTOR INDEX (embedding) );
Note that the indexed vector column must be NOT NULL
.
There are two options that can be used to configure the vector index. For example,
CREATE TABLE embeddings ( doc_id BIGINT UNSIGNED PRIMARY KEY, embedding VECTOR(1536) NOT NULL, VECTOR INDEX (embedding) M=8 DISTANCE=cosine );
Comments
Comments loading...
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.