Inserting embeddings into PostgreSQL fails with a dimension error, or creating an index fails because my vectors are too large.
Why this happens
A pgvector column is declared with a fixed size, such as vector(1536), and PostgreSQL rejects any vector of a different length. Separately, pgvector's HNSW and IVFFlat indexes support up to 2,000 dimensions for the standard vector type. Models like text-embedding-3-large (3,072 dimensions) exceed that limit.
Answer 1: Change the column to match your model
If the table is empty, or you're going to re-embed everything anyway, change the column type. Drop any vector index on the column first, then recreate it:
DROP INDEX IF EXISTS items_embedding_idx;
TRUNCATE items; -- old vectors have the wrong size and can't be converted
ALTER TABLE items ALTER COLUMN embedding TYPE vector(768);
CREATE INDEX items_embedding_idx ON items USING hnsw (embedding
vector_cosine_ops);
