Re: tuplesort memory usage: grow_memtuples - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: tuplesort memory usage: grow_memtuples
Date
Msg-id CAEYLb_XB0kVy-x4wt31bQgHan-Stvfzvchy-Q-XdJ-S_8XfxOg@mail.gmail.com
Whole thread Raw
In response to Re: tuplesort memory usage: grow_memtuples  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: tuplesort memory usage: grow_memtuples  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On 15 November 2012 18:13, Robert Haas <robertmhaas@gmail.com> wrote:
> Ah, yeah.  I wondered in passing about that but forgot to follow up on
> it.  The problem specifically is that the intermediate result
> memtupsize * newmemtuples might overflow.  I believe that the old
> memtupsize can never be more than 2^26 bytes, because the allocation
> limit is 1GB and each SortTuple is 16 bytes.

Do you mean the intermediate result of memtupsize * allowedMem? Oh,
yeah, that could overflow rather easily on a platform where long is
only 32-bit. We're multiplying the entire current allocation size of
the array by the maximum length. I guess the fact that you didn't spot
it made me overconfident. :-)

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



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: WIP patch: add (PRE|POST)PROCESSOR options to COPY
Next
From: Robert Haas
Date:
Subject: Re: tuplesort memory usage: grow_memtuples