summaryrefslogtreecommitdiff
path: root/src/backend/executor/instrument.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-04-16 20:07:35 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-04-16 20:07:35 +0000
commitd8b1bf47918aafdc515729624ad1ec2db4b91d14 (patch)
tree666046eec1e911ef6593a5fe6db6b3e938607a73 /src/backend/executor/instrument.c
parent85eee28ceca0814384392020c6c9a8269f213510 (diff)
downloadpostgresql-d8b1bf47918aafdc515729624ad1ec2db4b91d14.tar.gz
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.
Diffstat (limited to 'src/backend/executor/instrument.c')
-rw-r--r--src/backend/executor/instrument.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/backend/executor/instrument.c b/src/backend/executor/instrument.c
index 52d9de4f4a..c5b4a252d6 100644
--- a/src/backend/executor/instrument.c
+++ b/src/backend/executor/instrument.c
@@ -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;