CREATE TABLE with Vectors
Create tables optimized for vector storage. Learn to define columns with the VECTOR data type and configure vector indexes for similarity search.
MariaDB has a dedicated VECTOR(N) data type with a built-in data validation. N is the number of dimensions that all vector values in the column have.
Consider the following table:
CREATE TABLE embeddings (
doc_id BIGINT UNSIGNED PRIMARY KEY,
embedding VECTOR(1536)
);To have a fast vector search, you have 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)
);There are two options that can be used to configure the vector index:
M— Larger values mean slowerSELECTandINSERTstatements, larger index size and higher memory consumption, but more accurate results. The valid range is from3to200.DISTANCE— Distance function to build the vector index for. Searches using a different distance function will not be able to use a vector index. Valid values arecosineandeuclidean(the default).
This page is licensed: CC BY-SA / Gnu FDL
Last updated
Was this helpful?

