Re: Automatically setting work_mem - Mailing list pgsql-hackers

From Csaba Nagy
Subject Re: Automatically setting work_mem
Date
Msg-id 1142608064.16487.34.camel@coppola.muc.ecircle.de
Whole thread Raw
In response to Re: Automatically setting work_mem  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Automatically setting work_mem
List pgsql-hackers
> My own thoughts about the problems with our work_mem arrangement are
> that the real problem is the rule that we can allocate work_mem per sort
> or hash operation; this makes the actual total memory use per backend
> pretty unpredictable for nontrivial queries.  I don't know how to fix
> this though.  The planner needs to know the work_mem that will be used
> for any one of these operations in order to estimate costs, so simply
> trying to divide up work_mem among the operations of a completed plan
> tree is not going to improve matters.

I know this is not "right to the point" related to what is discussed in
this thread, and that it would need some serious work, but how about a
mechanism to allow plans some flexibility at run-time ? What I mean is
not to do all the decisions at plan time, but include some "branches" in
the plan, and execute one branch or the other depending on actual
parameter values, current statistics, current memory available, ...
(name here other run-time resources).

This would make a lot more feasible to long-term cache query plans. For
e.g. you wouldn't have to worry too much about changing statistics if at
runtime you can check them again... and you could put decision points
based on current memory resources. Of course it still must be a balance
between the number of the decision points (which ultimately means the
size of the plan) and robustness against changing conditions, i.e.
branches should only go in for conditions likely to change.

Is this completely not feasible with current postgres architecture ? I
have no idea how the planning/runtime works internally.

It worths a look at how apache Derby does with query planning, where a
planned query is actually a compiled Java class, i.e. the executable
byte code which will run to fetch the results, created and compiled by
the planner... interesting approach, allows for lots of flexibility at
run-time, but probably won't work with C :-)

Cheers,
Csaba.




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Commit turns into rollback?
Next
From: Peter Eisentraut
Date:
Subject: Re: Commit turns into rollback?