Re: pgsql: Support parallel btree index builds.

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pgsql: Support parallel btree index builds.
Date: 2021-06-08 00:47:59
Message-ID: CAH2-Wz=PfSBQd9thn22kx90mntfTig4GKjFx9SWF08B4=0Q22Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Mon, Jun 7, 2021 at 4:11 PM Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
> Now, if you do look at _bt_leafbuild(), it can be seen that nothing is
> done differently there either; we're not actually skipping any calls to
> tuplesort_performsort(). Any differentiation between serial/leader/
> worker cases seems to be done inside that routine. So the comment is
> not very useful there either.
>
> I am wondering if these comments are leftovers from early development
> versions of this patch. Maybe we could remove them -- or rewrite them
> to indicate not that we avoid calling tuplesort_performsort(), but
> instead to say that that function behaves differently.

It's talking about something described in the tuplesort.h contract. It
applies to a tuplesort state, not a process -- the leader always has two
tuplesort states (the leader tuplesort state, plus its own worker
tuplesort state).

The leader tuplesort is very much like a serial tuplesort. In
particular, as step 8 in tuplesort.h points out, the leader doesn't
have to call tuplesort_performsort() for the leader tuplesort state if
it already knows that there is no input to sort.

This matters less than it might in a world where we had a user of
parallel tuplesort that doesn't always simply make the leader
participate as a worker. There is a build-time testing option in
nbtsort.c that does this for parallel CREATE INDEX, actually -- see
DISABLE_LEADER_PARTICIPATION.

You kind of have a point about this being something that made more
sense in revisions of the patch from before commit, though. There was
a question about the cost model and the role of the leader that was
ultimately resolved by inventing the current simple behavior. So
feel free to change the wording now.

--
Peter Geoghegan

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2021-06-08 04:41:33 pgsql: Remove unnecessary declaration in win32_port.h
Previous Message Michael Paquier 2021-06-08 00:05:32 pgsql: Reorder superuser check in pg_log_backend_memory_contexts()

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro Horiguchi 2021-06-08 01:05:36 Re: Logical replication keepalive flood
Previous Message tsunakawa.takay@fujitsu.com 2021-06-08 00:47:08 RE: Transactions involving multiple postgres foreign servers, take 2