// troubleshooting guide · pgvector
pgvector HNSW Index Build Slow
- Status
- Workaround available
- platforms:
- All Postgres hosts
- updated:
- November 15, 2026
- reports:
- 4
- Method
- how we research
RUNBOOK · pgvector/slow-hnsw-index-build3 FIXES
// quick answer
HNSW builds slow down sharply when the graph no longer fits in maintenance_work_mem. Raise it for the session, add parallel workers and load data first.
Most likely fix: Raise maintenance_work_mem for the session
How to fix it
// try these in order, the most common fix is first
FIX 1Raise maintenance_work_mem for the session
- 01Run SET maintenance_work_mem = '8GB'; in the session that builds the index
- 02Neon suggests staying under about 50 to 60 percent of compute RAM
- 03Do not set it so high that the server runs out of memory
Did this fix it?FIX 2Add parallel workers
- 01SET max_parallel_maintenance_workers = 7;
- 02Raise max_parallel_workers (default 8) if needed
Did this fix it?FIX 3Load before you index
- 01Insert data first, then create the index
- 02Use CREATE INDEX CONCURRENTLY in production
- 03Monitor with pg_stat_progress_create_index
Did this fix it?
Symptoms
CREATE INDEX USING hnsw runs for hours and the log shows: hnsw graph no longer fits into maintenance_work_mem.
Why it happens
- C-01maintenance_work_mem too low
- C-02Default parallel maintenance workers (2)
- C-03Large table with high dimensions
- C-04Small instance
// this guide also covers
- pgvector hnsw index slow
- hnsw graph no longer fits into maintenance_work_mem
- pgvector index build time
Still not working?
If pgvector keeps failing, you're not alone. See every pgvector problem users report or the alternatives people switch to.
Have an app idea? Our small team builds any software: web and mobile apps, games, desktop, AI tools. Price agreed together.
Talk to usThe same problem in other apps
Other pgvector errors
- pgvector Error: extension "vector" is not available
- pgvector "operator does not exist: vector <=>" Error
- pgvector Dimension Limit: Cannot Index More Than 2000 Dimensions
- pgvector "different vector dimensions" Error
- pgvector Query Returns Fewer Results Than LIMIT With Filter
- pgvector Index Not Being Used
- pgvector HNSW Build Out of Memory or Shared Memory Error
- How to Enable pgvector on Supabase