mirror of
https://github.com/postgres/postgres.git
synced 2025-06-26 12:21:12 +03:00
Revise TupleTableSlot code to avoid unnecessary construction and disassembly
of tuples when passing data up through multiple plan nodes. A slot can now hold either a normal "physical" HeapTuple, or a "virtual" tuple consisting of Datum/isnull arrays. Upper plan levels can usually just copy the Datum arrays, avoiding heap_formtuple() and possible subsequent nocachegetattr() calls to extract the data again. This work extends Atsushi Ogawa's earlier patch, which provided the key idea of adding Datum arrays to TupleTableSlots. (I believe however that something like this was foreseen way back in Berkeley days --- see the old comment on ExecProject.) A test case involving many levels of join of fairly wide tables (about 80 columns altogether) showed about 3x overall speedup, though simple queries will probably not be helped very much. I have also duplicated some code in heaptuple.c in order to provide versions of heap_formtuple and friends that use "bool" arrays to indicate null attributes, instead of the old convention of "char" arrays containing either 'n' or ' '. This provides a better match to the convention used by ExecEvalExpr. While I have not made a concerted effort to get rid of uses of the old routines, I think they should be deprecated and eventually removed.
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/executor/executor.h,v 1.116 2005/03/14 04:41:13 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/executor/executor.h,v 1.117 2005/03/16 21:38:09 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -17,17 +17,6 @@
|
||||
#include "executor/execdesc.h"
|
||||
|
||||
|
||||
/*
|
||||
* TupIsNull
|
||||
*
|
||||
* This is used mainly to detect when there are no more
|
||||
* tuples to process.
|
||||
*/
|
||||
/* return: true if tuple in slot is NULL, slot is slot to test */
|
||||
#define TupIsNull(slot) \
|
||||
((slot) == NULL || (slot)->val == NULL)
|
||||
|
||||
|
||||
/*
|
||||
* ExecEvalExpr was formerly a function containing a switch statement;
|
||||
* now it's just a macro invoking the function pointed to by an ExprState
|
||||
@ -50,20 +39,18 @@ extern bool ExecMayReturnRawTuples(PlanState *node);
|
||||
/*
|
||||
* prototypes from functions in execGrouping.c
|
||||
*/
|
||||
extern bool execTuplesMatch(HeapTuple tuple1,
|
||||
HeapTuple tuple2,
|
||||
TupleDesc tupdesc,
|
||||
int numCols,
|
||||
AttrNumber *matchColIdx,
|
||||
FmgrInfo *eqfunctions,
|
||||
MemoryContext evalContext);
|
||||
extern bool execTuplesUnequal(HeapTuple tuple1,
|
||||
HeapTuple tuple2,
|
||||
TupleDesc tupdesc,
|
||||
int numCols,
|
||||
AttrNumber *matchColIdx,
|
||||
FmgrInfo *eqfunctions,
|
||||
MemoryContext evalContext);
|
||||
extern bool execTuplesMatch(TupleTableSlot *slot1,
|
||||
TupleTableSlot *slot2,
|
||||
int numCols,
|
||||
AttrNumber *matchColIdx,
|
||||
FmgrInfo *eqfunctions,
|
||||
MemoryContext evalContext);
|
||||
extern bool execTuplesUnequal(TupleTableSlot *slot1,
|
||||
TupleTableSlot *slot2,
|
||||
int numCols,
|
||||
AttrNumber *matchColIdx,
|
||||
FmgrInfo *eqfunctions,
|
||||
MemoryContext evalContext);
|
||||
extern FmgrInfo *execTuplesMatchPrepare(TupleDesc tupdesc,
|
||||
int numCols,
|
||||
AttrNumber *matchColIdx);
|
||||
@ -92,6 +79,8 @@ extern JunkFilter *ExecInitJunkFilterConversion(List *targetList,
|
||||
TupleTableSlot *slot);
|
||||
extern bool ExecGetJunkAttribute(JunkFilter *junkfilter, TupleTableSlot *slot,
|
||||
char *attrName, Datum *value, bool *isNull);
|
||||
extern TupleTableSlot *ExecFilterJunk(JunkFilter *junkfilter,
|
||||
TupleTableSlot *slot);
|
||||
extern HeapTuple ExecRemoveJunk(JunkFilter *junkfilter, TupleTableSlot *slot);
|
||||
|
||||
|
||||
@ -158,17 +147,6 @@ extern void ExecAssignScanProjectionInfo(ScanState *node);
|
||||
/*
|
||||
* prototypes from functions in execTuples.c
|
||||
*/
|
||||
extern TupleTable ExecCreateTupleTable(int tableSize);
|
||||
extern void ExecDropTupleTable(TupleTable table, bool shouldFree);
|
||||
extern TupleTableSlot *MakeTupleTableSlot(void);
|
||||
extern TupleTableSlot *ExecAllocTableSlot(TupleTable table);
|
||||
extern TupleTableSlot *ExecStoreTuple(HeapTuple tuple,
|
||||
TupleTableSlot *slot,
|
||||
Buffer buffer,
|
||||
bool shouldFree);
|
||||
extern TupleTableSlot *ExecClearTuple(TupleTableSlot *slot);
|
||||
extern void ExecSetSlotDescriptor(TupleTableSlot *slot,
|
||||
TupleDesc tupdesc, bool shouldFree);
|
||||
extern void ExecInitResultTupleSlot(EState *estate, PlanState *planstate);
|
||||
extern void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate);
|
||||
extern TupleTableSlot *ExecInitExtraTupleSlot(EState *estate);
|
||||
@ -183,6 +161,7 @@ typedef struct TupOutputState
|
||||
{
|
||||
/* use "struct" here to allow forward reference */
|
||||
struct AttInMetadata *metadata;
|
||||
TupleTableSlot *slot;
|
||||
DestReceiver *dest;
|
||||
} TupOutputState;
|
||||
|
||||
|
Reference in New Issue
Block a user