mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
Create memory context for HashAgg with a reasonable maxBlockSize.
If the memory context's maxBlockSize is too big, a single block allocation can suddenly exceed work_mem. For Hash Aggregation, this can mean spilling to disk too early or reporting a confusing memory usage number for EXPLAN ANALYZE. Introduce CreateWorkExprContext(), which is like CreateExprContext(), except that it creates the AllocSet with a maxBlockSize that is reasonable in proportion to work_mem. Right now, CreateWorkExprContext() is only used by Hash Aggregation, but it may be generally useful in the future. Discussion: https://postgr.es/m/412a3fbf306f84d8d78c4009e11791867e62b87c.camel@j-davis.com
This commit is contained in:
@ -3277,10 +3277,7 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
|
||||
}
|
||||
|
||||
if (use_hashing)
|
||||
{
|
||||
ExecAssignExprContext(estate, &aggstate->ss.ps);
|
||||
aggstate->hashcontext = aggstate->ss.ps.ps_ExprContext;
|
||||
}
|
||||
aggstate->hashcontext = CreateWorkExprContext(estate);
|
||||
|
||||
ExecAssignExprContext(estate, &aggstate->ss.ps);
|
||||
|
||||
|
Reference in New Issue
Block a user