aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/execJunk.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-03-14 04:41:13 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-03-14 04:41:13 +0000
commita9b05bdc8330b378cd2df7910ca0beaa500223fa (patch)
tree18be88094b6d17df65925023582e84c34bf152db /src/backend/executor/execJunk.c
parentd1022ce3a1a8b61798028a8fae46e7e458d77cff (diff)
downloadpostgresql-a9b05bdc8330b378cd2df7910ca0beaa500223fa.tar.gz
postgresql-a9b05bdc8330b378cd2df7910ca0beaa500223fa.zip
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.
Diffstat (limited to 'src/backend/executor/execJunk.c')
-rw-r--r--src/backend/executor/execJunk.c34
1 files changed, 7 insertions, 27 deletions
diff --git a/src/backend/executor/execJunk.c b/src/backend/executor/execJunk.c
index 5087c7bfc39..f747976acfa 100644
--- a/src/backend/executor/execJunk.c
+++ b/src/backend/executor/execJunk.c
@@ -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;
}
/*