Skip to Content
We are live but in Staging 🎉

Quickstart

Five minutes from here you’ll have a table with a vector<n> column, a few embeddings in it, and a working KNN query — all on the data plane, no pipeline and no engine to provision. A vector<n> column is just another column type.

Want K3 to embed uploaded documents for you? That’s the vector pipeline, and it lives in Pipelines → Quickstartdodil data vector collection add with an *_embedding_index template. This page is the pure-SQL path: you already have (or will insert) the vectors.

Prerequisites

  • dodil CLI installed and dodil auth login done — CLI Basics
  • A bucket — kb-prod:
    dodil data bucket create kb-prod -d "Vector demo"
  • A Postgres connection string for the pg wire (for the psql tab):
    dodil data connect kb-prod # emits a pg URL ending in ?sslmode=require
    Use sslmode=require — the pg wire terminates TLS. Avoid prefer: it silently falls back to plaintext, and your password on this wire is your service-account secret.

1. Create a table with a vector column

Pick your embedding dimension up front — the dimension is mandatory and fixed at create time. This demo uses 4-D vectors so you can type them by hand; real embeddings are 768/1024/1536-D.

CREATE TABLE items ( id VARCHAR PRIMARY KEY, content VARCHAR, embedding vector(4) );

2. Insert some vectors

A vector literal is a bracketed list in a string: '[0.1, 0.2, 0.3, 0.4]'.

INSERT INTO items (id, content, embedding) VALUES ('a', 'red apple', '[0.9, 0.1, 0.0, 0.1]'), ('b', 'green apple', '[0.8, 0.2, 0.0, 0.1]'), ('c', 'blue car', '[0.0, 0.1, 0.9, 0.2]');

3. Query — KNN by vector

Nearest neighbours to [0.85, 0.15, 0.0, 0.1] (near the apples). The three pgvector operators are <=> cosine, <-> L2, <#> inner product.

SELECT id, content, embedding <=> '[0.85, 0.15, 0.0, 0.1]' AS distance FROM items ORDER BY distance LIMIT 3;

Results come back ascending — lower distance is closer. The apples rank above the car.

4. (Optional) Add an ANN index

For large tables, back the column with an approximate index. Small tables are fine on exact scan.

CREATE INDEX ON items USING hnsw (embedding vector_cosine_ops) WITH (m = 16, ef_construction = 64);

The opclass must match how you query: vector_cosine_ops for <=>, vector_l2_ops for <->, vector_ip_ops for <#>. Only those three resolve. See Core Concepts → The ANN index.

What you just built

StepSurfaceResult
1CREATE TABLE … vector(4) on the tables-gatewaya vector collection (= a table)
2SQL INSERT / dodil data table upsertrows with embeddings
3<=> KNN / dodil data vsearchranked nearest neighbours
4CREATE INDEX … USING hnswan ANN index

The same table also answers a stock Qdrant or Pinecone client — see External Collection.

Next steps

Cleanup

dodil data table delete items -b kb-prod dodil data bucket delete kb-prod