1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

Tweak default memory context allocation policy so that a context is not

given any malloc block until something is first allocated in it; but
thereafter, MemoryContextReset won't release that first malloc block.
This preserves the quick-reset property of the original policy, without
forcing 8K to be allocated to every context whether any of it is ever
used or not.  Also, remove some more no-longer-needed explicit freeing
during ExecEndPlan.
This commit is contained in:
Tom Lane
2002-12-15 21:01:34 +00:00
parent 5bab36e9f6
commit e64c7feb2f
11 changed files with 66 additions and 99 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.33 2002/12/12 15:49:28 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.34 2002/12/15 21:01:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -63,8 +63,6 @@ JunkFilter *
ExecInitJunkFilter(List *targetList, TupleDesc tupType,
TupleTableSlot *slot)
{
MemoryContext oldContext;
MemoryContext junkContext;
JunkFilter *junkfilter;
List *cleanTargetList;
int len,
@ -79,19 +77,6 @@ ExecInitJunkFilter(List *targetList, TupleDesc tupType,
AttrNumber *cleanMap;
Expr *expr;
/*
* Make a memory context that will hold the JunkFilter as well as all
* the subsidiary structures we are about to create. We use smaller-
* than-default sizing parameters since we don't expect a very large
* volume of stuff here.
*/
junkContext = AllocSetContextCreate(CurrentMemoryContext,
"JunkFilterContext",
1024,
1024,
ALLOCSET_DEFAULT_MAXSIZE);
oldContext = MemoryContextSwitchTo(junkContext);
/*
* First find the "clean" target list, i.e. all the entries in the
* original target list which have a false 'resjunk' NOTE: make copy
@ -174,33 +159,14 @@ ExecInitJunkFilter(List *targetList, TupleDesc tupType,
junkfilter->jf_cleanLength = cleanLength;
junkfilter->jf_cleanTupType = cleanTupType;
junkfilter->jf_cleanMap = cleanMap;
junkfilter->jf_junkContext = junkContext;
junkfilter->jf_resultSlot = slot;
if (slot)
ExecSetSlotDescriptor(slot, cleanTupType, false);
MemoryContextSwitchTo(oldContext);
return junkfilter;
}
/*-------------------------------------------------------------------------
* ExecFreeJunkFilter
*
* Release the data structures created by ExecInitJunkFilter.
*-------------------------------------------------------------------------
*/
void
ExecFreeJunkFilter(JunkFilter *junkfilter)
{
/*
* Since the junkfilter is inside its own context, we just have to
* delete the context and we're set.
*/
MemoryContextDelete(junkfilter->jf_junkContext);
}
/*-------------------------------------------------------------------------
* ExecGetJunkAttribute
*