Re: tuplesort memory usage: grow_memtuples

From: Peter Geoghegan <peter(at)2ndquadrant(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tuplesort memory usage: grow_memtuples
Date: 2012-11-15 17:29:19
Message-ID: CAEYLb_UmQQLzgquM8b-fpgKKHLPpQGjw3mvZThFEtsXNJ=Ze5A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 15 November 2012 16:09, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> I'm still not too sure why this part is OK:
>
> /* This may not be our first time through */
> if (newmemtupsize <= memtupsize)
> return false;
>
> Suppose we enlarge the memtuples array by something other than a
> multiple of 2, and then we kick out all of the tuples that are
> currently in memory and load a new group with a smaller average size.
> ISTM that it could now appear that the memtuples array can be useful
> further enlarged, perhaps by as little as one tuple, and that that
> this could happen repeatedly. I think we should either refuse to grow
> the array unless we can increase it by at least, say, 10%, or else set
> a flag after the final enlargement that acts as a hard stop to any
> further growth.

I thought that the flag added to Tuplesortstate in earlier revisions
was a little bit ugly. I can see the concern though, and I suppose
that given the alternative is to add a heuristic, simply using a flag
may be the best way to proceed.

--
Peter Geoghegan http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training and Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2012-11-15 17:53:15 another idea for changing global configuration settings from SQL
Previous Message Peter Geoghegan 2012-11-15 17:14:54 Re: tuplesort memory usage: grow_memtuples