DocumentationNeuronDB Documentation
Documentation Branch: You are viewing documentation for the main branch (3.0.0-devel). Select a branch to view its documentation:

Vector Types

Vector Types

NeuronDB provides multiple vector types optimized for different use cases.

vector (Standard)

32-bit floating-point vectors for general-purpose use.

CREATE TABLE documents (
    id SERIAL PRIMARY KEY,
    content TEXT,
    embedding vector(384)
);

INSERT INTO documents (content, embedding)
VALUES ('Hello world', '[1.0, 2.0, 3.0]'::vector);

vectorp (Packed)

Optimized storage layout for faster memory access.

SELECT vectorp_in('[0.1, 0.2, 0.3, 0.4]')::text;

vecmap (Sparse)

Stores only non-zero values, ideal for sparse data.

SELECT vecmap_in('{
    "dim": 10000,
    "nnz": 3,
    "indices": [0, 5, 9999],
    "values": [1.5, 2.3, 0.8]
}')::text;

vgraph (Graph-Based)

For graph structures with connectivity information.

SELECT vgraph_in('{
    "nodes": 5,
    "edges": [[0, 1], [1, 2]]
}')::text;

rtext (Retrieval Text)

Specialized type for retrieval-optimized text.

SELECT rtext_in('retrieval optimized text');

sparse_vector (Sparse Vector)

Stores sparse vectors efficiently, ideal for high-dimensional sparse data.

CREATE TABLE sparse_docs (
    id SERIAL PRIMARY KEY,
    content TEXT,
    embedding sparse_vector
);

-- Sparse vectors store only non-zero values
INSERT INTO sparse_docs (content, embedding)
VALUES ('Document text', sparse_vector_in('{0: 1.5, 100: 2.3, 1000: 0.8}'));

Learn More

For detailed documentation on all vector types, when to use each, storage optimization, and performance characteristics, visit:

Vector Types Documentation