Excerpts from Robert Haas's message of jue jun 09 10:55:45 -0400 2011:
> On Thu, Jun 9, 2011 at 10:34 AM, Alvaro Herrera
> <alvherre@commandprompt.com> wrote:
> > Slower than sleeping? Consider that this doesn't need to be done for
> > each record insertion, only when you need to flush (maybe more than
> > that, but I think that's the lower limit).
>
> Maybe. I'm worried that if someone jacks up max_connections to 1000
> or 5000 or somesuch it could get pretty slow.
Well, other things are going to get pretty slow as well, not just this
one, which is why we suggest using a connection pooler with a reasonable
limit.
On the other hand, maybe those are things we ought to address sometime,
so perhaps we don't want to be designing the old limitation into a new
feature.
A possibly crazy idea: instead of having a MaxBackends-sized array, how
about some smaller array of insert-done-pointer-updating backends (a
couple dozen or so), and if it's full, the next one has to sleep a bit
until one of them becomes available. We could protect this with a
PGSemaphore having as many counts as items are in the array.
--
Álvaro Herrera <alvherre@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support