// 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
Share

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

  1. FIX 1Raise maintenance_work_mem for the session

    1. 01Run SET maintenance_work_mem = '8GB'; in the session that builds the index
    2. 02Neon suggests staying under about 50 to 60 percent of compute RAM
    3. 03Do not set it so high that the server runs out of memory
    Did this fix it?
  2. FIX 2Add parallel workers

    1. 01SET max_parallel_maintenance_workers = 7;
    2. 02Raise max_parallel_workers (default 8) if needed
    Did this fix it?
  3. FIX 3Load before you index

    1. 01Insert data first, then create the index
    2. 02Use CREATE INDEX CONCURRENTLY in production
    3. 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 us

Watch pgvector Get an email when its price changes, it has an outage, or we publish a new fix. No spam.

Fixed it? Share this guide

The same problem in other apps

All export, render & quality loss guides →

Other pgvector errors

All 11 pgvector errors and fixes →