On Mon, 2004-12-06 at 19:37 -0500, Paul Tillotson wrote:
> I seem to remember hearing that the memory limit on certain operations,
> such as sorts, is not "enforced" (may the hackers correct me if I am
> wrong); rather, the planner estimates how much a sort might take by
> looking at the statistics for a table.
>
> If the statistics are wrong, however, the sort doesn't actually stay
> within sort memory, and so the process consumes a very large amount of
> memory, much more than the sort_mem configuration parameter should allow
> it to.
AFAIK this is not the case. sort_mem defines the in-memory buffer used
_per_ sort operation. The problem you may be referring to is that
multiple concurrent sort operations (possibly within a single backend)
will each consume up to sort_mem, so the aggregate memory usage for sort
operations may be significantly higher than sort_mem.
-Neil