Re: Massive memory use for star query - Mailing list pgsql-bugs

From Greg Stark
Subject Re: Massive memory use for star query
Date
Msg-id BANLkTi=_qXQi2D=qSNhd+mRkHZ-r6k8Qpw@mail.gmail.com
Whole thread Raw
In response to Re: Massive memory use for star query  (Mark Kirkwood <mark.kirkwood@catalyst.net.nz>)
Responses Re: Massive memory use for star query  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
On Sat, Apr 16, 2011 at 8:21 AM, Mark Kirkwood
<mark.kirkwood@catalyst.net.nz> wrote:
>
> I guess you have answered my first question - i.e yes this should eat
> massive amount of ram as written - however are you sure there is no memory
> leaking going on here?

The planner doesn't try to free up memory while it's working, it
generally assumes that producing a plan is a short process and when
it's done it'll free the whole context and that's enough.

The basic problem is that the number of possible plans blows up
combinatorically. That is with 14 tables there are 14! possible join
orderings and more something like 3^(14!) possible join strategies --
actually more if you include things like whether to materialize and
which keys to use and so on.

The planner uses various heuristics to avoid combinatoric growth
wherever it can but there's no way to completely avoid it.
--
greg

pgsql-bugs by date:

Previous
From: Mark Kirkwood
Date:
Subject: Re: Massive memory use for star query
Next
From: Tom Lane
Date:
Subject: Re: Massive memory use for star query