---
title: Index Build
---

### Maintenance Working Memory

The default Postgres `maintenance_work_mem` value of `64MB` is quite conservative and can significantly slow down index builds. For large indexes,
we strongly recommend increasing `maintenance_work_mem`.

```bash postgresql.conf
maintenance_work_mem = 16GB
```

`maintenance_work_mem` should not exceed the server's available memory.

### Indexing Memory per Process

<Note>This setting requires superuser privileges.</Note>

`paradedb.create_index_memory_budget` defaults to `1024MB`. It sets the amount of memory to dedicate per indexing process before the index segment needs to be
written to disk. The value is measured in megabytes. In terms of raw indexing performance, larger is generally better.

If set to `0`, `maintenance_work_mem` divided by [indexing parallelism](#parallel-indexing-processes) will be used.

The final calculated per-process memory budget is capped to 4GB.

```sql
SET paradedb.create_index_memory_budget = 2048;
```

In addition to improving build times, this setting also affects the number of segments created in the index. This is because, while ParadeDB tries to maintain as many segments as CPUs, a segment that cannot fit into memory will be split into a new segment. As a result, an insufficient `paradedb.create_index_memory_budget` can lead to significantly more segments than available CPUs, which degrades search performance. To check if the chosen value value is high enough, you can compare the index’s segment count with the server’s CPU count.

### Parallel Indexing Processes

ParadeDB uses Postgres' `max_parallel_maintenance_workers` setting to determine the degree of parallelism during `CREATE INDEX`/`REINDEX`. Postgres' default is `2`, which may not be a reasonable number depending on the table's size.

Consider using a value closer to the number of CPU threads on the host computer.

```sql
SET max_parallel_maintenance_workers = 8;
```
