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.Documentation Index
Fetch the complete documentation index at: https://docs.turso.tech/llms.txt
Use this file to discover all available pages before exploring further.
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:| Function | Precision | Storage per dimension | Best for |
|---|---|---|---|
vector32 | 32-bit float | 4 bytes | Most ML embeddings (OpenAI, sentence transformers) |
vector64 | 64-bit float | 8 bytes | Applications requiring higher precision |
Sparse Vectors
Sparse vectors only store non-zero values and their indices, making them memory-efficient for high-dimensional data with many zero values.| Function | Storage | Best for |
|---|---|---|
vector32_sparse | Non-zero values + indices | TF-IDF, bag-of-words, high-dimensional sparse data |
Quantized Vectors
| Function | Storage per dimension | Best for |
|---|---|---|
vector8 | 1 byte (+8 bytes overhead) | Large-scale search where ~4x compression vs Float32 is worth minimal precision loss |
f_i = alpha * q_i + shift.
Binary Vectors
| Function | Storage per dimension | Best for |
|---|---|---|
vector1bit | 1 bit | Binary hashing, approximate nearest neighbor search (~32x compression vs Float32) |
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:Similarity Search
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).Euclidean (L2) Distance
Measures straight-line distance in n-dimensional space. Not supported forvector1bit vectors.
Dot Product Distance
Computes the negative dot product:-sum(v1[i] * v2[i]). Lower (more negative) values indicate higher similarity.
Jaccard Distance
Computes weighted Jaccard distance based on the ratio of minimum to maximum values across dimensions. Forvector1bit vectors, computes binary Jaccard distance.
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
vector1bitvectors - Maximum vector dimensionality is 65,536
vector1bitcosine distance returns Hamming distance (number of differing bits) instead of standard cosine distance
Example: Semantic Search
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
- Vector Functions — full SQL reference for all vector functions
- Data Types — how BLOBs are handled in Turso