Thread: create index in parallel?

create index in parallel?

From
"Angva"
Date:
Hi, looking for a little advice...

Nightly, I run a script that does the following (in a nutshell): drop
most of the indexes in a particular schema; load a large amount of data
into this schema; finally recreate the indexes.

The create index process seems to be CPU-bound. The server has four
CPUs but postmaster is only using one. Is there a way to tell Postgres
to build in parallel? For instance in Oracle one can run the following
to have four processes build an index in parallel:

CREATE INDEX emp_ix ON emp (emp_id)
   PARALLEL (DEGREE 4);

I could always create each index from a separate script in parallel,
but that would be less flexible (can't easily modify degree for
instance) and take some serious redesign... No luck searching the docs,
but I'd just like to be sure that there isn't such a feature... Or if
there's a better way to tackle this problem I'd love to hear it.

So, any input would be appreciated.

Thanks,
Mark