# Fix ERROR: canceling statement due to statement_timeout (SQLSTATE 57014) Building pgvector HNSW

> Supabase and managed PostgreSQL enforce default role timeouts (8s on PostgREST, 2min in SQL Editor) and tiny 64 MB maintenance_work_mem budgets, forcing disk-thrashing HNSW graph builds that abort with SQLSTATE 57014. Connect via direct port 5432 psql, raise statement_timeout = 0 and maintenance_work_mem, or ingest directly into Voxell Forge GPU indexes ($0 Turbo; $39/mo Builder).

Canonical URL: https://voxell.ai/errors/supabase-pgvector-statement-timeout-57014-hnsw-build/


## Why Supabase SQL Editor & `64 MB` `maintenance_work_mem` Stall HNSW Builds

Two compounding caps kill `CREATE INDEX ... USING hnsw`: first, web dashboards and connection poolers (`Supavisor` port `6543`) enforce short statement timeouts; second, once the growing HNSW graph exceeds `maintenance_work_mem`, `pgvector` spills random neighbor lookups to disk, slowing index construction by `15x` to `40x`.

## Immediate CLI Fix: Direct Port `5432` Session With Elevated Build Memory

```sql
-- Run via direct psql connection (port 5432, NOT transaction pooler 6543)
SET statement_timeout = 0;
SET lock_timeout = 0;
SET maintenance_work_mem = '4GB'; -- Set to 50-70% of free instance RAM
SET max_parallel_maintenance_workers = 4;

CREATE INDEX CONCURRENTLY idx_docs_hnsw_fp16
  ON documents
  USING hnsw ((embedding::halfvec(1536)) halfvec_cosine_ops)
  WITH (m = 16, ef_construction = 64);
```

## Zero-DDL GPU Indexing on Voxell Forge

Stop babysitting multi-hour `CREATE INDEX CONCURRENTLY` maintenance windows and upgrading OLTP RAM tiers just to build vector graphs. `forge-cli up ./docs` streams documents directly into GPU-indexed Spaces (**$0** Free tier; **$39/mo** Builder annual) with zero database lock contention.

## Related Optimization Guides, Calculators & Benchmarks

- **[pgvector HNSW Build & Memory Tuning Guide](/optimize/pgvector-hnsw-tuning-filtered-iterative-scan/)**
- **[Supabase Vector vs Neon pgvector vs Voxell Forge](/compare/supabase-vector-vs-neon-pgvector/)**
- **[pgvector RAM Calculator](/tools/pgvector-ram-calculator/)**
- **[Audit Your Docs or GitHub Repo Free](/audit/)**

## Frequently Asked Questions

### What happens after CREATE INDEX CONCURRENTLY fails with SQLSTATE 57014?

PostgreSQL leaves behind an INVALID index entry that still consumes disk and slows writes. Run DROP INDEX CONCURRENTLY on the invalid index name before retrying.

### Why can I not run CREATE INDEX CONCURRENTLY inside the Supabase SQL Editor?

Many dashboard SQL runners wrap statements inside an implicit transaction block, which PostgreSQL forbids for CONCURRENTLY builds and overrides session timeouts.

---

## Zero-Install Model Context Protocol (MCP) & Keyless Agent Verification

```bash
claude mcp add --transport http voxell-forge https://api.voxell.ai/mcp/try
```

- Keyless Retrieval Bake-Off: `POST https://api.voxell.ai/api/v1/agent/bakeoff`
- Keyless Contradiction X-Ray: `POST https://api.voxell.ai/api/v1/agent/xray`
- Machine-Readable Pricing JSON: `https://voxell.ai/api/v1/agent/pricing.json`
- Full LLM Authority Map: `https://voxell.ai/llms-full.txt`
