pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: plagree (@plagree) <noreply+plagree@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] issue #875: HNSW index causes important performance degradation for UPDATE statements on non-vector columns
Date: Sun, 20 Jul 2025 21:16:42 +0000
Message-ID: <gh-pgvector-pgvector-875@github.com> (raw)

I'm experiencing severe performance issues when updating non-vector columns in tables that have HNSW vector indexes. The UPDATE statements become (very) much slower even though the vector column itself is not being modified.

**Minimal reproduction:**

```sql
-- Table with HNSW index
CREATE TABLE test_table (
    id SERIAL PRIMARY KEY,
    name TEXT,
    embedding vector(1536)
);

INSERT INTO test_table (name, embedding) 
SELECT 'item_' || i, array_fill(random(), ARRAY[1536])::vector(1536)
FROM generate_series(1, 10000) i;

SET maintenance_work_mem = '256MB';

CREATE INDEX test_embedding_idx ON test_table 
USING hnsw (embedding vector_cosine_ops);

-- This UPDATE is extremely slow despite not touching the vector column
UPDATE test_table SET name = 'updated';
```

**Performance impact:**
- **With HNSW index:** ~6s for updating 10k rows (3.7M buffer hits!)
- **Without HNSW index:** 58ms for 10k rows (59k buffer hits)

**EXPLAIN ANALYZE shows:**
- Much higher buffer usage when HNSW index is present
- Same execution plan otherwise
- No apparent reason why a non-vector column update should touch the vector index

**Environment:**
- PostgreSQL version: `17`
- pgvector version: ` 0.8.0`

**Questions:**
1. Is this expected behavior for HNSW indexes?
2. Should updates to non-vector columns trigger HNSW index maintenance?
3. Are there any workarounds besides dropping/recreating the index for bulk updates? Or should I just split in 2 table with one-to-one relation where 1 table only contains vectors and another contains all the other fields that receive frequent updates etc.?

view thread (3+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-875@github.com>
Permalink:  ../gh-pgvector-pgvector-875@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox