# pgvector vs MySQL VECTOR vs SQL Server VECTOR: Where Embeddings Can Be Searched, Not Just Stored

> All three store a 1,536-dimension embedding, but only pgvector served a nearest-neighbour search from an index that still took writes. MySQL 9.7 Community refuses any index on a `VECTOR` column and has no distance function, so the search happens outside the database. SQL Server 2025 computes exact distances, and its approximate vector index is a preview that, on the build we ran, made the table refuse every write.

Source: https://schemity.com/blog/pgvector-vs-mysql-vs-sql-server-vector/

Only pgvector gave us an approximate nearest-neighbour index on embeddings that served the search and still accepted writes; MySQL 9.7 Community stores vectors but cannot index them or compute a distance between them, and SQL Server 2025 computes exact distances but made an indexed table read-only on the build we tested. So the choice is less about the column type, which all three have, and more about where the similarity search will run.

We took one pgvector design and moved it with Schemity's SQL conversion to MySQL 9.7.4 (Community) and SQL Server 2025 (17.0.5035.5, RTM-CU10), then ran each script on the real server. The design is a test table built to exercise every pgvector column type and both of its index methods, so a real table would keep one of the two indexes, not both. On PostgreSQL 17.11 with pgvector 0.8.7:

```sql
CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE documents (
  id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
  title TEXT NOT NULL,
  embedding VECTOR(1536) NOT NULL,
  summary_embedding HALFVEC(768),
  keywords SPARSEVEC(30000)
);
CREATE INDEX documents_embedding_hnsw ON documents
  USING hnsw (embedding vector_cosine_ops) WITH (m = 16, ef_construction = 64);
CREATE INDEX documents_embedding_ivfflat ON documents
  USING ivfflat (embedding vector_l2_ops) WITH (lists = 100);
```

## pgvector vs MySQL VECTOR vs SQL Server VECTOR: which should store your embeddings?

Use pgvector when the database has to find the nearest embeddings itself, SQL Server 2025 when an exact search that reads every row is fast enough, and MySQL Community only to store vectors that another system searches.

| | PostgreSQL 17 + pgvector 0.8.7 | MySQL 9.7.4 Community | SQL Server 2025 (17.0.5035.5) |
|---|---|---|---|
| Column type | `vector`, `halfvec`, `sparsevec` | `VECTOR(n)`, single precision only | `VECTOR(n)`; `VECTOR(n, float16)` only with `PREVIEW_FEATURES` |
| Most dimensions | 16,000; indexed, 2,000 (4,000 for `halfvec`) | 16,383 | 1,998 (3,996 for float16) |
| Distance in SQL | `<=>`, `<->`, `<#>` operators | None: `DISTANCE()` is not in Community | `VECTOR_DISTANCE`, exact |
| Approximate index | HNSW and IVFFlat | Refused, error 6134 | `CREATE VECTOR INDEX`, preview only |
| Writes with the index in place | Yes | No index to write to | Refused, Msg 42231 |

pgvector ran the source design unchanged. On a table of 5,000 embeddings with the HNSW index, `EXPLAIN` showed the nearest-neighbour query `ORDER BY embedding <=> ... LIMIT 5` as an `Index Scan using documents_embedding_hnsw`, and an `UPDATE` and an `INSERT` both succeeded with the index in place. The one warning came from IVFFlat: built on the still-empty table, it printed "ivfflat index created with little data" and "This will cause low recall", because IVFFlat chooses its list centres from the rows that exist when the index is built.

## What MySQL 9.7 does with a VECTOR column

MySQL 9.7 Community stores vectors, but it can neither index them nor compute a distance between two of them.

The converted script ran: `embedding` became `VECTOR(1536)`, `summary_embedding` a single-precision `VECTOR(768)`, and `keywords` a `LONGTEXT`, since MySQL has no sparse vector. `VECTOR_DIM(embedding)` returned 1536 on an inserted row. Then the limits showed. `CREATE INDEX x ON documents (embedding)` failed with `ERROR 6134 (HY000): Non-scalar (e.g., vector) column 'embedding' cannot be used as key`, and both `DISTANCE(embedding, embedding, 'COSINE')` and `VECTOR_DISTANCE(...)` failed with error 1305, function does not exist. MySQL's [vector functions page](https://dev.mysql.com/doc/refman/9.7/en/vector-functions.html) explains the second: `DISTANCE()` "is available only for users of MySQL HeatWave on OCI and MySQL AI; it is not included in MySQL Commercial or Community distributions."

![Schemity's canvas reading the converted documents table from MySQL 9.7.4: id BIGINT auto, embedding VECTOR(1536), keywords LONGTEXT nullable, summary_embedding VECTOR(768) nullable and title TEXT, with the Field details panel for summary_embedding showing type VECTOR(768), not a key, nullable](https://schemity.com/images/blog/pgvector-vs-mysql-vs-sql-server-vector/mysql-canvas-vector-columns.webp)

So on MySQL Community the database is a vector store in the literal sense: every similarity query has to read candidate vectors out and rank them in the application. If the rest of the application lives in MySQL, the options are MySQL HeatWave or MySQL AI, a separate vector index next to MySQL, or a PostgreSQL database for the embeddings alone.

## What SQL Server 2025 does with a VECTOR column

SQL Server 2025 computes exact distances out of the box, and its approximate index is a preview that, on the build we ran, left the table read-only.

The converted script failed on the first try. `summary_embedding VECTOR(768, float16)` returned `Msg 195: 'float16' is not a recognized vector base type`, and the [vector data type page](https://learn.microsoft.com/en-us/sql/t-sql/data-types/vector-data-type) says why: in SQL Server 2025, "half-precision (**float16**) vectors are available in preview", behind the `PREVIEW_FEATURES` database scoped configuration. With `ALTER DATABASE SCOPED CONFIGURATION SET PREVIEW_FEATURES = ON` the same column was accepted, and `sys.columns` reported it with `vector_base_type` 1, against 0 for float32. Exact search needed no preview at all: `VECTOR_DISTANCE('cosine', v, @q)` ranked rows correctly.

The approximate index is where it stops. Microsoft's [CREATE VECTOR INDEX page](https://learn.microsoft.com/en-us/sql/t-sql/statements/create-vector-index-transact-sql) requires at least 100 rows with vectors, so we built it on a separate 300-row test table, `e`, with a `VECTOR(3)` column `v`. `CREATE VECTOR INDEX e_v_idx ON e(v) WITH (METRIC = 'cosine', TYPE = 'diskann')` was an unknown statement until `PREVIEW_FEATURES` was on, and it needed `QUOTED_IDENTIFIER ON`. Once built, `VECTOR_SEARCH` worked, and every `INSERT`, `UPDATE` and `DELETE` failed with `Msg 42231: Data modification statement failed because table 'e' has a vector index on it`. The same page describes a newer index version that "is no longer read-only", and an `ALLOW_STALE_VECTOR_INDEX` setting for the older one, but on 17.0.5035.5 the index carried no version number in `sys.vector_indexes` and the server did not recognise `ALLOW_STALE_VECTOR_INDEX`. On that build, a vector index is not usable on a table that takes new embeddings; check your own build before planning on one.

## How Schemity converts a vector design between databases

Schemity Pro converts a vector design to MySQL, SQL Server or Snowflake, and from the next release its script header names what the target cannot keep, and why.

Schemity is database design software that reads your live database, shows the impact of every schema change before it runs, and keeps the diagram as a file in Git. It reads and writes vector columns on PostgreSQL, MySQL, SQL Server and Snowflake: pgvector's `vector`, `halfvec` and `sparsevec` with their dimensions, MySQL 9's `VECTOR(n)`, SQL Server 2025's `VECTOR(n)` and its float16 form from `sys.columns`, and Snowflake's `VECTOR(FLOAT, n)`; SQL Server and Snowflake are part of Schemity Pro. With Schemity Pro, the [SQL export can convert](https://schemity.com/doc/export-sql-ddl/) a diagram to another database, as it did for this post. An excerpt of the SQL Server script's header, as the next release writes it:

```
-- Converted by Schemity from PostgreSQL to SQL Server. The diagram itself is unchanged.
-- Type mappings:
--   HALFVEC(768) -> VECTOR FLOAT16(768) (1 column): SQL Server 2025 takes float16 vectors only with PREVIEW_FEATURES on (Azure SQL takes them as they are).
--   SPARSEVEC(30000) -> NVARCHAR(MAX) (1 column): SQL Server has no sparse vector; stored as text.
-- Notes:
--   documents: HNSW index documents_embedding_hnsw is left out: SQL Server's CREATE VECTOR INDEX needs PREVIEW_FEATURES, and on SQL Server 2025 17.0.5035 the table then refuses writes.
--   documents: IVFFLAT index documents_embedding_ivfflat is left out: SQL Server's CREATE VECTOR INDEX needs PREVIEW_FEATURES, and on SQL Server 2025 17.0.5035 the table then refuses writes.
```

![Schemity's Diagram SQL dialog converting the PostgreSQL documents design to SQL Server: the summary lists HALFVEC(768) to VECTOR FLOAT16(768) with the note that SQL Server 2025 takes float16 vectors only with PREVIEW_FEATURES on, SPARSEVEC(30000) to NVARCHAR(MAX), and the HNSW and IVFFLAT indexes left out because SQL Server's CREATE VECTOR INDEX needs PREVIEW_FEATURES and on 17.0.5035 the table then refuses writes; below, the 20-line script with embedding VECTOR(1536) NOT NULL and summary_embedding VECTOR(768, float16)](https://schemity.com/images/blog/pgvector-vs-mysql-vs-sql-server-vector/convert-to-sqlserver-header.webp)

Running the scripts on the real servers is how those lines came to exist. The released conversion writes `VECTOR(768, float16)` for SQL Server with no warning, a script that fails as it stands, and it lists the HNSW and IVFFlat indexes as left out for being "on an expression or a column prefix, with a `WHERE` or with `NULLS NOT DISTINCT`", a reason that has nothing to do with them. Both are fixed for the next release, where the MySQL header says that MySQL "has no vector index and refuses any index on a `VECTOR` column". That is how to design the next one when it has to live on more than one database: decide where the search runs, then let the column type follow.

## Which database should hold the embeddings

Put embeddings where their search runs, which today means PostgreSQL with pgvector for anything that needs an index and takes writes.

If the embeddings belong in PostgreSQL, [where to put the column](https://schemity.com/blog/pgvector-embedding-column-vs-separate-table/) is the next decision, and the same conversion notes cover the rest of a schema in [MySQL to PostgreSQL schema conversion](https://schemity.com/blog/mysql-to-postgresql-schema-conversion/).

## Frequently asked questions

### Can MySQL do vector similarity search?

Not in MySQL Community Server. It stores a `VECTOR(n)` column up to 16,383 dimensions, but MySQL's manual says `DISTANCE()` is available only in MySQL HeatWave on OCI and MySQL AI, and MySQL 9.7.4 refused an index on a `VECTOR` column with error 6134. Nearest neighbours have to be found in the application or in another system.

### Does SQL Server 2025 have a vector index?

As a preview. `CREATE VECTOR INDEX` needs `PREVIEW_FEATURES` turned on, and on SQL Server 2025 17.0.5035.5 every `INSERT`, `UPDATE` and `DELETE` on the indexed table then failed with Msg 42231. Microsoft documents a newer index version that takes writes, but that build did not build it. `VECTOR_DISTANCE`, which computes an exact distance without an index, worked with no preview setting.

### What happens to a pgvector halfvec column in SQL Server?

SQL Server has a half-precision `VECTOR(n, float16)`, but SQL Server 2025 refused it with Msg 195 until `PREVIEW_FEATURES` was turned on; Azure SQL takes it without that setting. Without it, use a single-precision `VECTOR(n)`, which takes twice the space per dimension.
