> > What would the benefit of this be? sort_mem is just an upper limit on
> > memory consumption, and that memory is only allocated on demand. So
> > there shouldn't be a difference between setting sort_mem globally to
> > some reasonable value, and manually changing it for backends that need
> > to do any sorting.
>
> Well, while that is correct, setting sort mem high only when required
would
> prevent memory exhaustion if that happens.
>
> Remember he has 5000 requests per minute with concurrent connection. Now
say
> there is a default high setting of sort mem and a connection persist for a
long
> time, it *might* accumulate memory. Personally I would not keep it high by
> default.
Could you elaborate on what exactly is a query requiring sorting (and
therefore is affected by sort_mem setting)?
Is it a SELECT with WHERE-clause using seq scan? Is it rebuilding of an
index? What else could it be?
Regards,
Bjoern