mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
Create a new 'MultiExecProcNode' call API for plan nodes that don't
return just a single tuple at a time. Currently the only such node type is Hash, but I expect we will soon have indexscans that can return tuple bitmaps. A side benefit is that EXPLAIN ANALYZE now shows the correct tuple count for a Hash node.
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
* Copyright (c) 2001-2005, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/instrument.c,v 1.11 2005/03/25 21:57:58 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/instrument.c,v 1.12 2005/04/16 20:07:35 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -33,13 +33,10 @@ InstrAlloc(int n)
|
||||
void
|
||||
InstrStartNode(Instrumentation *instr)
|
||||
{
|
||||
if (!instr)
|
||||
return;
|
||||
|
||||
if (!INSTR_TIME_IS_ZERO(instr->starttime))
|
||||
elog(DEBUG2, "InstrStartNode called twice in a row");
|
||||
else
|
||||
if (INSTR_TIME_IS_ZERO(instr->starttime))
|
||||
INSTR_TIME_SET_CURRENT(instr->starttime);
|
||||
else
|
||||
elog(DEBUG2, "InstrStartNode called twice in a row");
|
||||
}
|
||||
|
||||
/* Exit from a plan node */
|
||||
@ -48,12 +45,13 @@ InstrStopNode(Instrumentation *instr, bool returnedTuple)
|
||||
{
|
||||
instr_time endtime;
|
||||
|
||||
if (!instr)
|
||||
return;
|
||||
/* count the returned tuples */
|
||||
if (returnedTuple)
|
||||
instr->tuplecount += 1;
|
||||
|
||||
if (INSTR_TIME_IS_ZERO(instr->starttime))
|
||||
{
|
||||
elog(DEBUG2, "InstrStopNode without start");
|
||||
elog(DEBUG2, "InstrStopNode called without start");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -86,9 +84,17 @@ InstrStopNode(Instrumentation *instr, bool returnedTuple)
|
||||
instr->running = true;
|
||||
instr->firsttuple = INSTR_TIME_GET_DOUBLE(instr->counter);
|
||||
}
|
||||
}
|
||||
|
||||
if (returnedTuple)
|
||||
instr->tuplecount += 1;
|
||||
/* As above, but count multiple tuples returned at once */
|
||||
void
|
||||
InstrStopNodeMulti(Instrumentation *instr, double nTuples)
|
||||
{
|
||||
/* count the returned tuples */
|
||||
instr->tuplecount += nTuples;
|
||||
|
||||
/* delegate the rest */
|
||||
InstrStopNode(instr, false);
|
||||
}
|
||||
|
||||
/* Finish a run cycle for a plan node */
|
||||
@ -97,14 +103,14 @@ InstrEndLoop(Instrumentation *instr)
|
||||
{
|
||||
double totaltime;
|
||||
|
||||
if (!instr)
|
||||
return;
|
||||
|
||||
/* Skip if nothing has happened, or already shut down */
|
||||
if (!instr->running)
|
||||
return;
|
||||
|
||||
/* Accumulate statistics */
|
||||
if (!INSTR_TIME_IS_ZERO(instr->starttime))
|
||||
elog(DEBUG2, "InstrEndLoop called on running node");
|
||||
|
||||
/* Accumulate per-cycle statistics into totals */
|
||||
totaltime = INSTR_TIME_GET_DOUBLE(instr->counter);
|
||||
|
||||
instr->startup += instr->firsttuple;
|
||||
|
Reference in New Issue
Block a user