Randomize the choice of the initial ROUNDROBIN node
authorTomas Vondra <[email protected]>
Sun, 11 Jun 2017 13:30:59 +0000 (15:30 +0200)
committerTomas Vondra <[email protected]>
Sat, 17 Jun 2017 21:28:49 +0000 (23:28 +0200)
commit1d14325822e41fee5edc529ee8776a1dd22bda06
treee1b4e6877da41563ae57a6d55b8b0a6407afe9d2
parent93656ace7562bf6892764d314311c802fbfdc34f
Randomize the choice of the initial ROUNDROBIN node

With roundrobin node, the initial node was always set to the first node
in the list. That works fine when inserting many rows at once (e.g. with
INSERT SELECT), but with single-row inserts this puts all data on the
first node, resulting in unbalanced distribution.

This randomizes the choice of the initial node, so that with single-row
inserts the ROUNDROBIN behaves a bit like RANDOM distribution.

This also removes unnecessary srand() call from RelationBuildLocator(),
located after a call to rand().
src/backend/pgxc/locator/locator.c