Skip to main content
Turso supports vector search as a native feature — no extensions required. Store vector embeddings alongside your relational data and query them using built-in distance functions for similarity search.

Vector Types

Turso supports dense, sparse, quantized, and binary vector representations, each suited to different workloads.

Dense Vectors

Dense vectors store a value for every dimension. Turso provides two precision levels:

Sparse Vectors

Sparse vectors only store non-zero values and their indices, making them memory-efficient for high-dimensional data with many zero values.

Quantized Vectors

Values are linearly quantized to the 0-255 range using min/max scaling. Dequantization: f_i = alpha * q_i + shift.

Binary Vectors

Positive values become 1, non-positive values become 0. Extracted values are displayed as +1/-1.
For most applications, vector32 is a good starting point. Explore more compact types if your table has a large number of rows.

Storing Vectors

Create a table with a BLOB column to store embeddings alongside your relational data:
Insert rows with vector embeddings using the appropriate conversion function:
For sparse vectors, zero values are automatically compressed:
Use distance functions to find the most similar vectors. All distance functions require both vectors to have the same type and dimensionality. Lower values indicate greater similarity.

Cosine Distance

Measures the angle between vectors, ignoring magnitude. Returns a value between 0 (identical direction) and 2 (opposite direction).
Best for text embeddings and document similarity where direction matters more than magnitude.

Euclidean (L2) Distance

Measures straight-line distance in n-dimensional space. Not supported for vector1bit vectors.
Best for image embeddings, spatial data, and unnormalized embeddings where absolute differences matter.

Dot Product Distance

Computes the negative dot product: -sum(v1[i] * v2[i]). Lower (more negative) values indicate higher similarity.
Best for normalized embeddings (equivalent to cosine distance when vectors are unit-length) and maximum inner product search (MIPS).

Jaccard Distance

Computes weighted Jaccard distance based on the ratio of minimum to maximum values across dimensions. For vector1bit vectors, computes binary Jaccard distance.
Best for sparse vectors, set-like comparisons, TF-IDF representations, and binary similarity with vector1bit.

Utility Functions

vector_extract

Convert a vector BLOB back to a readable JSON representation:

vector_concat

Concatenate two vectors into one:

vector_slice

Extract a contiguous portion of a vector (zero-based, end exclusive):

Limitations

  • Euclidean distance is not supported for vector1bit vectors
  • Maximum vector dimensionality is 65,536
  • vector1bit cosine distance returns Hamming distance (number of differing bits) instead of standard cosine distance
A complete end-to-end example combining vector storage and similarity search:
Similarity searches use a linear scan over the table. For large datasets, consider limiting the search to a subset of rows with a WHERE clause.

See Also