pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Building lots of indices in parallel
Date: Thu, 11 Feb 2021 21:31:40 -0600
Message-ID: <7fa62c6a-dfab-4d0e-17cc-e4030f83fcc9@gmail.com> (raw)


We're migrating a big database (200ish tables 30 of which have bytea or xml 
fields; the Oracle size is 10TB) to Postgresql 12.5 (RDS, if it matters), 
and after the loads are completed, it will be time to create the secondary 
indices (tables currently only have PK constraints), and they of course need 
to be built as fast as possible.

The first things to do are based in Postgres itself:
ALTER TABLE foo SET (parallel_workers = 4);
SET max_parallel_maintenance_workers TO 4;
CREATE INDEX foo_ind2 ON foo (f1);

That creates one index very quickly, but only one index at a time, wasting 
the other CPUs (there are 48 in the VM, and 384GB RAM).

What is the impact on locking/contention of using something like GNU 
Parallel (especially when it tries to create multiple indices on the same 
table in parallel)?

Is there a better way to quickly create lots of indices?

-- 
Angular momentum makes the world go 'round.





Message-ID: <7fa62c6a-dfab-4d0e-17cc-e4030f83fcc9@gmail.com>
Permalink:  ../7fa62c6a-dfab-4d0e-17cc-e4030f83fcc9@gmail.com/
Also on:    postgresql.org/message-id/7fa62c6a-dfab-4d0e-17cc-e4030f83fcc9@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: ronljohnsonjr@gmail.com
  Subject: Re: Building lots of indices in parallel
  In-Reply-To: <7fa62c6a-dfab-4d0e-17cc-e4030f83fcc9@gmail.com>
  References: <7fa62c6a-dfab-4d0e-17cc-e4030f83fcc9@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox