Glossary
Vector database vs relational database
A relational database stores structured rows and answers exact queries with SQL, while a vector database stores embeddings and answers similarity queries by finding the nearest vectors to a query.
A relational database and a vector database answer different kinds of question. A relational database such as PostgreSQL or MySQL stores structured data in tables with defined columns and answers exact questions with SQL: which orders over $500 shipped last week, which users belong to this account. A vector database stores embeddings, lists of numbers that represent the meaning of text, images or audio, and answers approximate questions: which passages are closest in meaning to this query. Relational databases guarantee correctness, consistency and transactions over well-defined data. Vector databases trade exactness for the ability to search unstructured content by meaning, using approximate nearest-neighbour indexes. Many AI applications use both, and extensions such as pgvector let a relational database store and search vectors too, which blurs the line for small and medium workloads.
How a relational database works
A relational database organises data into tables of rows and columns, with a schema that defines types and constraints. Relationships between tables are expressed with keys and resolved at query time with joins. SQL lets you filter, aggregate, sort and join with precise semantics, and the database uses B-tree and other indexes to make those operations fast. Transactions with ACID guarantees mean that a payment and the matching ledger entry either both happen or neither does, and constraints stop invalid data from being written in the first place.
The model is built for questions with exact answers. Is this invoice paid? How many seats does this customer have? What changed in this record since Tuesday? Text search exists, through full-text search features based on an inverted index, but it matches words rather than meaning. A query for “late payment penalties” will not find a clause that says “interest accrues on overdue balances” unless it shares the right terms.
How a vector database works
A vector database stores an embedding for each item, produced by an embedding model so that items with similar meaning end up close together in a space with hundreds or thousands of dimensions. A query is embedded the same way, and vector search returns the stored items nearest to it by a measure such as cosine similarity. An exact scan of every vector is too slow at scale, so vector databases build an approximate nearest neighbor index such as HNSW or an IVF index, and often compress vectors with vector quantization to fit more in memory.
Each vector carries metadata, and metadata filtering restricts a search to items that match conditions such as tenant, date or document type. The result is a ranked list with similarity scores, not a set of rows that satisfy a predicate. Two runs with slightly different index settings can return slightly different results, and the top result is the most similar item, which is not always the correct one.
Vector database vs relational database at a glance
| Relational database | Vector database |
|---|---|---|
Data model | Tables of typed rows and columns | Items with embeddings and metadata |
Query language | SQL | Similarity search API, sometimes with filters |
Type of answer | Exact rows that satisfy a condition | Ranked items by closeness in meaning |
Indexes | B-tree, hash, inverted index for text | HNSW, IVF and other ANN indexes |
Strength | Correctness, joins, aggregates, transactions | Semantic search over unstructured content |
Weakness | No notion of meaning | Approximate, no joins, weak on exact facts |
Consistency | Strong, with ACID transactions | Varies; often eventually consistent indexes |
Typical AI use | Users, accounts, billing, permissions, app state | RAG retrieval, recommendations, deduplication |
Examples | PostgreSQL, MySQL, SQL Server | Pinecone, Weaviate, Qdrant, Milvus |
pgvector and the middle ground
The boundary is less sharp than it was. The pgvector extension adds a vector column type, distance operators and approximate indexes to PostgreSQL, so embeddings can live in the same database as the rows they describe. That has real advantages: one system to run, transactional updates of vectors and metadata together, joins between search results and application tables, and familiar tooling for backups and access control. Several managed databases, including document and search engines, have added vector search in a similar way.
The trade-offs appear at scale and under load. Dedicated vector databases are built around the memory and compute profile of ANN search, with features such as sharded indexes, quantization options and high write throughput for re-embedding. A general-purpose database can handle millions of vectors comfortably, and many teams never need more, but performance tuning, index build times and the interaction between filters and approximate search need attention as collections grow. Comparisons such as pgvector vs Pinecone and Exabase vs pgvector look at specific products.
Freshness and the cost of change
The two systems also behave differently when data changes. Updating a row in a relational database is cheap and immediately visible to the next query. Updating content behind a vector means re-extracting the source, re-chunking it, calling the embedding model again and replacing the old vectors, and approximate indexes may take time to absorb large batches of changes. Switching to a new embedding model is more expensive still, because every stored vector has to be regenerated before old and new embeddings can be compared. Teams that skip this work end up with stale knowledge in the index long after the source document was corrected, which is one of the more common reasons a RAG system answers confidently from an outdated version. Planning for re-indexing, and tracking which source version each vector came from, matters as much as choosing the database.
Where each one fits in an AI application
Most AI products need both kinds of storage. The relational database holds the system of record: users, accounts, subscriptions, permissions, documents’ ownership and status, and the application’s own state. These are facts with exact answers, and they need transactions and constraints. The vector side holds what needs to be found by meaning: chunks of documents for retrieval, product descriptions for recommendations, support tickets for duplicate detection.
The usual pattern is to search vectors for candidates, then use relational data to filter, enrich and authorise them. A RAG query finds the ten most relevant passages, then checks in the relational database that the user may see each source document, and attaches titles and links. Hybrid search adds keyword matching through BM25 or a similar method so that exact names, codes and SKUs are not lost, which is where pure vector search tends to struggle. The post on semantic search vs keyword search for AI agents covers that balance.
Multi-tenancy: a common pain point
Tenant isolation looks different in each system. In a relational database it is often handled with a tenant column and row-level security policies that the database enforces on every query. In vector databases it is usually a metadata filter on tenant ID or a separate vector namespace per tenant. Filters fail silently the first time a query forgets them, and namespaces isolate vectors but not the files, metadata and extraction outputs around them. The multi-tenant solution page and the post a WHERE clause is not tenant isolation go into the problem, and tenant isolation defines the term.
Neither one is a memory system
Agents that need to remember users across sessions often reach for one of these databases first. A relational table of user facts is exact but has to be written by code that decides in advance what to store. A vector store of conversation chunks is flexible but returns old and new facts side by side, because similarity has no idea that one fact replaced another. Agent memory sits on top of storage and handles extraction, contradiction resolution and recency, as why a vector database is not a memory system explains. Vector database vs graph database covers the third common storage model, where relationships themselves are the data.
A worked example
A legal tech company stores 400,000 contracts for 300 law firm customers. The relational database holds firms, users, matters, contract metadata such as parties, dates and status, and who can access each matter. Queries such as “contracts expiring in the next 90 days for this firm” run in SQL and return exact results.
Lawyers also ask “find clauses similar to this indemnity language across our matters”. That needs clause-level embeddings and similarity search. The team first stored embeddings with pgvector in the same PostgreSQL instance, which worked well up to a few million clauses and let them join results directly to matters and permissions. As volume grew and every firm needed strict separation, they had to decide between per-tenant indexes, a dedicated vector service, or a platform that handles extraction, indexing and isolation together.
Where Exabase fits
Exabase does not replace your relational database, which should stay the system of record for users, billing and application state. It also does not expose a raw vector database. It provides the layer that teams usually build on top of a vector store. Files, notes and links stored as Resources are extracted and indexed automatically, and Deep Search returns sub-document passages using hybrid semantic and keyword search, with filters for folder, tag, type and date and a precision setting per query. Listing and filtering resources by structured attributes uses the resources filter endpoint.
Isolation is handled with Bases: each customer gets a separate environment with its own storage, search index and memory, created with a single create Base call, so a scoped query cannot reach another tenant’s data whatever its filters say. For agent memory, the Memory API handles extraction and contradiction resolution that neither a relational table nor a vector store provides on its own. The multi-tenant SaaS use case shows how this sits next to an existing relational database.
Frequently asked questions
Can a relational database be used as a vector database?
Yes, with an extension such as pgvector for PostgreSQL, which adds a vector type, distance functions and approximate indexes. It works well for many workloads, especially when you want vectors and relational data in one transactional system. Very large or write-heavy vector workloads may be better served by a dedicated system.
Do I need a vector database if I already use PostgreSQL?
Not necessarily. For small and medium collections, pgvector is often enough. A separate vector system becomes worth considering when collections grow large, latency targets tighten, or you need features such as sharded indexes and extensive quantization options.
Is a vector database faster than SQL?
They are fast at different things. A relational database is faster and exact for structured filters, joins and aggregates. A vector database is faster at approximate similarity search over millions of embeddings. Comparing raw speed without the query type is not meaningful.
Can vector databases do joins?
Generally no. Most vector databases support metadata filters but not joins across collections. Applications usually retrieve candidates from the vector store and join them to relational data in application code or in a database that supports both.
Which is better for RAG?
RAG retrieval needs semantic or hybrid search, which vector databases and search engines provide. The relational database still holds document ownership, permissions and metadata used to filter and cite results. Most RAG systems use both.
Does Exabase replace my database?
No. Keep your relational database for users, billing and application state. Exabase provides storage, extraction, Deep Search and memory for unstructured content, scoped per Base, so you do not have to run your own vector index and ingestion pipeline.
Related pages: Vector database, Vector database vs graph database, Vector database vs knowledge graph, Hybrid search vs vector search, Row-level security, Multi-tenant, Exabase vs pgvector, Best vector databases, Best vector database for multi-tenant