Short answer
A vector store retrieves by similarity, and a document store retrieves by keys and queries. pgvector describes similarity search for Postgres, including nearest neighbors. MongoDB calls itself a document database of JSON-like documents, and its introduction also lists vector search. No latency figure is added here.
Last verified against the sources listed below.
Key takeaways
- pgvector stores vectors in Postgres and supports exact and approximate nearest-neighbor search.
- MongoDB's introduction calls MongoDB a document database with a query engine for JSON-like documents.
- A document's _id is the primary key. Queries use field names, including dot notation for nested fields.
- MongoDB's own overview lists vector search alongside document search, so that product describes both.
- The MongoDB document page sets a maximum BSON document size of 16 mebibytes.
A vector database vs nosql comparison is about how a lookup works. The pgvector README opens with “open-source vector similarity search for Postgres.” You store vectors with the rest of your data and ask for nearest neighbors. Exact and approximate search are both on that feature list.
MongoDB’s introduction calls MongoDB a document database. It stores flexible, JSON-like documents so the stored shape can follow the objects in your code. A record is a document of field and value pairs. Collections hold those documents and, unlike a rigid table, do not enforce one pre-defined schema.
The verdict is the retrieval style. A vector store returns rows that are close to a query vector. A document store returns documents by keys and queries on fields. Overlap belongs in the article only where a source claims it.
MongoDB’s introduction lists vector search as one workload type beside document-based search. pgvector’s README does not claim to be a document database.
What does similarity search return?
Similarity search returns the nearest stored vectors. pgvector supports single-precision, half-precision, binary, and sparse vectors. Distances on the feature list include L2, inner product, cosine, L1, Hamming, and Jaccard. Any language with a Postgres client can use it, according to the README.
The getting-started section creates a table with an id and a vector column, inserts a few vectors, and orders the rows by L2 distance to a query vector, with a limit. That is the whole idea in one query shape: closeness, not “the document whose title equals this string.” The README also points at Postgres features such as joins and point-in-time recovery, because the vectors live in Postgres.
Relational databases are the family Postgres belongs to. PostgreSQL’s about page calls it an open source object-relational system that uses and extends SQL, and it says you can define your own data types. pgvector is an extension in that tradition. The install notes say it supports Postgres 13 or newer, and the clone steps use branch v0.8.7.
What does a document database return?
A document database returns documents that match a key or a field query. MongoDB’s document page says a document is the basic unit of data, stored as BSON. The BSON spec calls BSON a binary-encoded serialization of JSON-like documents, and it says that role is why BSON is MongoDB’s primary data representation.
Field names are strings. The _id field is reserved as a primary key in a standard collection: unique, immutable, and not an array. If an insert omits _id, the driver or the server adds an ObjectId. Dot notation reaches into arrays and embedded documents, so a query can name name.last or an array index.
That is key-and-field retrieval. Similarity order is a different question.
The document page sets the maximum BSON document size at 16 mebibytes. It says the cap keeps one document from using an excessive amount of RAM or bandwidth, and it points larger files at GridFS. Nothing on that page describes nearest-neighbor order. The introduction is the page that adds other workload types.
Where does one product do both?
Say a product does both only when its own docs say so. MongoDB’s introduction lists document-based structured search, aggregation, full-text search, vector search, geospatial search, and time series as workload types. On that page, vector search is not a rumor. It is one bullet in the product’s own list, next to the document model.
pgvector does not make the same claim in reverse. It adds similarity search to Postgres. Postgres can also store JSON and JSONB, which the about page lists under document data types. Storing JSON in a column is still SQL storage plus a vector extension.
It is not the MongoDB document model, and the README does not say it replaces one. Enable the extension only in databases that should store vectors.
Machine learning is why teams store vectors at all: a model turns an item into a list of numbers, and search finds nearby lists. This article does not invent recall scores or millisecond budgets for that step. The README names distance operators. It does not publish a latency table.
How do the lookups compare?
The table contrasts the two retrieval styles using only the pages above. MongoDB’s extra vector-search bullet is called out so the overlap is not hidden and not exaggerated.
| Vector similarity (pgvector) | Document store (MongoDB) | |
|---|---|---|
| What you store | Vectors in a Postgres column, plus your other columns | BSON documents of fields and values |
| How you retrieve | Order by distance to a query vector | Primary key and queries on fields |
| Identity | A table key such as a bigserial id in the sample | _id on a standard collection |
| Nested data | Whatever SQL columns and JSON types you add | Embedded documents and arrays, reached with dot notation |
| Overlap the vendor states | Similarity search inside Postgres | Introduction lists both document search and vector search |
| Size note on the page opened | Dimension count on the column, such as vector(3) | 16 mebibyte BSON document maximum |
A word counter can tell you how long a text field is before you store it. That length is not a distance. Similarity depends on the vector and the operator, not on the word count of the original sentence.
Which lookup should you use?
Use similarity search when the question is “what is close to this,” and you already have vectors. pgvector’s sample is that question inside Postgres, so joins against the rest of the row stay available. Use it when the README’s distance list includes the comparison your vectors were built for, and when Postgres 13 or newer fits the install note.
Use document queries when the question is “the record with this id” or “fields that match this filter.” MongoDB’s model is built for that shape, including nested fields and a flexible schema. Use MongoDB’s vector-search workload only because the introduction lists it, and then read that feature’s own page before you design the index. This article did not open a separate vector-search tutorial, so it stops at the listing.
Use both styles in one product only after you have seen that product say so. For MongoDB, the introduction does. For a plain document query, you still do not get nearest neighbors by writing a field filter. For pgvector, you do not get a MongoDB collection by installing the extension.
What should you leave out?
Leave out invented latency. Neither the pgvector README nor the MongoDB pages opened here give a milliseconds number you can quote as a comparison. Distance operators and document size limits are not speed scores.
Leave out a claim that every NoSQL database is a vector database, or the reverse. The document model described above retrieves by keys and queries. Vector search is an added workload where a vendor lists it. A relational engine with an extension, which is pgvector’s own description, is a third arrangement: similarity search beside SQL, not a document store with a new name.
Frequently asked questions
Which pgvector version does the README install?
The README's Linux, Mac, and Windows install steps clone branch v0.8.7. The Linux notes say the extension supports Postgres 13 or newer. You enable it with CREATE EXTENSION vector inside each database that should store vectors. Those are install facts from the README, not a ranking against a document database. The same page shows a vector column declared with a dimension count, such as vector(3) in the getting-started example.
Which distance operators does the getting-started section name?
The getting-started queries order rows with the <-> operator for L2 distance. The README also names inner product as <#>, cosine distance as <=>, and L1 distance as <+>. Earlier on the page, the feature list adds Hamming distance and Jaccard distance. You pick an operator because it matches how the vectors were built. The README does not publish a milliseconds-per-query figure next to those symbols.
What is BSON, in the spec's words?
The BSON specification says BSON is a binary-encoded serialization of JSON-like documents. It supports embedded documents and arrays, plus types that are not in JSON, and it gives Date and BinData as examples. It says traversability matters because BSON is the primary data representation for MongoDB. MongoDB's document page says the database stores records as BSON and points readers at that spec.
Do time series collections require _id?
MongoDB's document page says each document in a standard collection needs a unique _id that acts as a primary key. If you omit it, the driver or server adds an ObjectId. The same page says time series collections do not require a unique _id, because MongoDB does not create an index on _id there. That exception is about keys, not about similarity search.
Does Postgres already store JSON?
PostgreSQL's about page lists JSON and JSONB under document data types, next to XML and hstore. That is a data type inside an object-relational database, which the page says uses and extends SQL. pgvector is an extension that adds vector similarity to that database. Storing a JSON value is not the same operation as ordering rows by distance to a query vector.
Sources
- pgvector README · pgvector, 2026
- What is MongoDB? · MongoDB, 2026
- Documents · MongoDB, 2026
- About · PostgreSQL, 2026
- BSON · BSON, 2026