1 /*-------------------------------------------------------------------------
4 * definitions for run-time statistics collection
7 * Copyright (c) 2001-2009, PostgreSQL Global Development Group
9 * $PostgreSQL: pgsql/src/include/executor/instrument.h,v 1.21 2009/12/15 04:57:48 rhaas Exp $
11 *-------------------------------------------------------------------------
16 #include "portability/instr_time.h"
19 typedef struct BufferUsage
21 long shared_blks_hit; /* # of shared buffer hits */
22 long shared_blks_read; /* # of shared disk blocks read */
23 long shared_blks_written; /* # of shared disk blocks written */
24 long local_blks_hit; /* # of local buffer hits */
25 long local_blks_read; /* # of local disk blocks read */
26 long local_blks_written; /* # of local disk blocks written */
27 long temp_blks_read; /* # of temp blocks read */
28 long temp_blks_written; /* # of temp blocks written */
31 typedef enum InstrumentOption
33 INSTRUMENT_TIMER = 1 << 0, /* needs timer */
34 INSTRUMENT_BUFFERS = 1 << 1, /* needs buffer usage */
35 INSTRUMENT_ALL = 0x7FFFFFFF
38 typedef struct Instrumentation
40 /* Info about current plan cycle: */
41 bool running; /* TRUE if we've completed first tuple */
42 bool needs_bufusage; /* TRUE if we need buffer usage */
43 instr_time starttime; /* Start time of current iteration of node */
44 instr_time counter; /* Accumulated runtime for this node */
45 double firsttuple; /* Time for first tuple of this cycle */
46 double tuplecount; /* Tuples emitted so far this cycle */
47 BufferUsage bufusage_start; /* Buffer usage at start */
48 /* Accumulated statistics across all completed cycles: */
49 double startup; /* Total startup time (in seconds) */
50 double total; /* Total total time (in seconds) */
51 double ntuples; /* Total tuples produced */
52 double nloops; /* # of run cycles for this node */
53 BufferUsage bufusage; /* Total buffer usage */
56 extern BufferUsage pgBufferUsage;
58 extern Instrumentation *InstrAlloc(int n, int instrument_options);
59 extern void InstrStartNode(Instrumentation *instr);
60 extern void InstrStopNode(Instrumentation *instr, double nTuples);
61 extern void InstrEndLoop(Instrumentation *instr);
63 #endif /* INSTRUMENT_H */