Re: [EXTERNAL] Re: Support load balancing in libpq - Mailing list pgsql-hackers

From Andrey Borodin
Subject Re: [EXTERNAL] Re: Support load balancing in libpq
Date
Msg-id CAAhFRxjKzhBRsa=PDnRn2-_6j1PwSXKRAGrmmkp613sim7pTDg@mail.gmail.com
Whole thread Raw
In response to Re: [EXTERNAL] Re: Support load balancing in libpq  (Jelte Fennema <postgres@jeltef.nl>)
Responses Re: [EXTERNAL] Re: Support load balancing in libpq  (Jelte Fennema <postgres@jeltef.nl>)
List pgsql-hackers
On Wed, Mar 1, 2023 at 12:03 PM Jelte Fennema <postgres@jeltef.nl> wrote:
>
> done and updated cf entry
>

Hi Jelte!

I've looked into the patch. Although so many improvements can be
suggested, It definitely makes sense as-is too.
These improvements might be, for example, sorting hosts according to
ping latency or something like that. Or, perhaps, some other balancing
policies. Anyway, randomizing is a good start too.

I want to note that the Fisher-Yates algorithm is implemented in a
difficult to understand manner.
+if (j < i) /* avoid fetching undefined data if j=i */
This stuff does not make sense in case of shuffling arrays inplace. It
is important only for making a new copy of an array and only in
languages that cannot access uninitialized values. I'd suggest just
removing this line (in both cases).


Best regards, Andrey Borodin.



pgsql-hackers by date:

Previous
From: Isaac Morland
Date:
Subject: Re: Remove source code display from \df+?
Next
From: Peter Smith
Date:
Subject: Re: [PATCH] Use indexes on the subscriber when REPLICA IDENTITY is full on the publisher