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

Avoid O(N^2) overhead in repeated nocachegetattr calls when columns of

a tuple are being accessed via ExecEvalVar and the attcacheoff shortcut
isn't usable (due to nulls and/or varlena columns).  To do this, cache
Datums extracted from a tuple in the associated TupleTableSlot.
Also some code cleanup in and around the TupleTable handling.
Atsushi Ogawa with some kibitzing by Tom Lane.
This commit is contained in:
Tom Lane
2005-03-14 04:41:13 +00:00
parent d1022ce3a1
commit a9b05bdc83
8 changed files with 378 additions and 300 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/execJunk.c,v 1.46 2004/12/31 21:59:45 pgsql Exp $
* $PostgreSQL: pgsql/src/backend/executor/execJunk.c,v 1.47 2005/03/14 04:41:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -209,20 +209,13 @@ ExecGetJunkAttribute(JunkFilter *junkfilter,
Datum *value,
bool *isNull)
{
List *targetList;
ListCell *t;
AttrNumber resno;
TupleDesc tupType;
HeapTuple tuple;
/*
* first look in the junkfilter's target list for an attribute with
* Look in the junkfilter's target list for an attribute with
* the given name
*/
resno = InvalidAttrNumber;
targetList = junkfilter->jf_targetList;
foreach(t, targetList)
foreach(t, junkfilter->jf_targetList)
{
TargetEntry *tle = lfirst(t);
Resdom *resdom = tle->resdom;
@ -231,26 +224,13 @@ ExecGetJunkAttribute(JunkFilter *junkfilter,
(strcmp(resdom->resname, attrName) == 0))
{
/* We found it ! */
resno = resdom->resno;
break;
*value = slot_getattr(slot, resdom->resno, isNull);
return true;
}
}
if (resno == InvalidAttrNumber)
{
/* Ooops! We couldn't find this attribute... */
return false;
}
/*
* Now extract the attribute value from the tuple.
*/
tuple = slot->val;
tupType = slot->ttc_tupleDescriptor;
*value = heap_getattr(tuple, resno, tupType, isNull);
return true;
/* Ooops! We couldn't find this attribute... */
return false;
}
/*