Vector search in SQL
Query vector columns with <=>, <->, <#>, backed by HNSW, IVFFlat, and DiskANN.
Built on Postgres — embeddings, vector search, hybrid retrieval, and AI functions in SQL. Your vectors live in the same rows as your data. No ETL.
PostgreSQL-compatible · AI and vector search callable from SQL · no ETL to a separate vector store.
Building AI features on Postgres usually means bolting a vector store onto your database, then keeping two systems in sync — embeddings drift from the rows they describe, and every query becomes a join you do in application code. TheoDB collapses that: embeddings, vector search, hybrid retrieval, and AI calls are all SQL, running next to the relational data they belong to.
Query vector columns with <=>, <->, <#>, backed by HNSW, IVFFlat, and DiskANN.
theodb.embed() writes the embedding and the row together, from your model endpoint.
ai.hybrid_search() combines full-text and vector similarity with RRF in one call.
ai.generate, ai.summarize, ai.analyze_sentiment, and ai.rank inside your queries.
ai.nl_query() turns a question into a validated, read-only SELECT over an allowlist.
Register endpoints with theodb_ml; any OpenAI-compatible provider. It stores no keys.
-- Semantic search + operational filter + AI summary, all in SQL
SELECT p.id,
p.description,
ai.summarize(p.description) AS gist
FROM products p
JOIN inventory i ON i.product_id = p.id
WHERE i.in_stock
AND p.category_id = 3
ORDER BY p.embedding <=> theodb.embed('lightweight trail shoes')
LIMIT 5;Vectors, a relational join, and AI — one statement, one transaction.
Most teams add retrieval by gluing a vector store, an embedding pipeline, and an LLM API onto a database that already holds the data. That glue is where staleness and complexity accumulate. Comparison at the capability level.
| Capability | TheoDB | pgvector + glue | Dedicated vector DB |
|---|---|---|---|
| Vectors + your data | Same rows, one database | Same DB, manual wiring | Separate store, synced via ETL |
| Embeddings | theodb.embed() in SQL | Call an API in app code | External pipeline |
| Generation & classify | ai.generate / ai.summarize in SQL | App code + AI API | Not offered |
| Hybrid (keyword + vector) | ai.hybrid_search() with RRF | Wire FTS + vector yourself | Varies |
| Drivers & tooling | PostgreSQL-compatible | Postgres | New client + query language |
One Postgres-compatible database where your vectors, your data, and your AI calls share the same query — instead of a vector DB, an embedding pipeline, and an AI service you keep in sync.
Every product team is adding retrieval and AI features, mostly by gluing systems onto a database that already holds the data. Keeping vectors and AI beside the rows they describe removes the sync problem before it starts.
Join the waitlist → theo login
Read the docs → docs.usetheo.dev