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