2001-09-17 21:59:07 -04:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* instrument.h
|
|
|
|
|
* definitions for run-time statistics collection
|
|
|
|
|
*
|
|
|
|
|
*
|
2016-01-02 13:33:40 -05:00
|
|
|
* Copyright (c) 2001-2016, PostgreSQL Global Development Group
|
2001-09-17 21:59:07 -04:00
|
|
|
*
|
2010-09-20 16:08:53 -04:00
|
|
|
* src/include/executor/instrument.h
|
2001-09-17 21:59:07 -04:00
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
#ifndef INSTRUMENT_H
|
|
|
|
|
#define INSTRUMENT_H
|
|
|
|
|
|
2008-05-14 15:10:29 -04:00
|
|
|
#include "portability/instr_time.h"
|
2005-03-20 17:27:52 -05:00
|
|
|
|
|
|
|
|
|
2009-12-14 23:57:48 -05:00
|
|
|
typedef struct BufferUsage
|
|
|
|
|
{
|
2012-06-10 15:20:04 -04:00
|
|
|
long shared_blks_hit; /* # of shared buffer hits */
|
2010-02-25 21:01:40 -05:00
|
|
|
long shared_blks_read; /* # of shared disk blocks read */
|
2012-02-22 20:33:05 -05:00
|
|
|
long shared_blks_dirtied; /* # of shared blocks dirtied */
|
2010-02-25 21:01:40 -05:00
|
|
|
long shared_blks_written; /* # of shared disk blocks written */
|
2012-06-10 15:20:04 -04:00
|
|
|
long local_blks_hit; /* # of local buffer hits */
|
|
|
|
|
long local_blks_read; /* # of local disk blocks read */
|
2012-02-22 20:33:05 -05:00
|
|
|
long local_blks_dirtied; /* # of shared blocks dirtied */
|
2010-02-25 21:01:40 -05:00
|
|
|
long local_blks_written; /* # of local disk blocks written */
|
2012-06-10 15:20:04 -04:00
|
|
|
long temp_blks_read; /* # of temp blocks read */
|
2010-02-25 21:01:40 -05:00
|
|
|
long temp_blks_written; /* # of temp blocks written */
|
2012-06-10 15:20:04 -04:00
|
|
|
instr_time blk_read_time; /* time spent reading */
|
|
|
|
|
instr_time blk_write_time; /* time spent writing */
|
2009-12-14 23:57:48 -05:00
|
|
|
} BufferUsage;
|
|
|
|
|
|
2011-09-22 11:29:18 -04:00
|
|
|
/* Flag bits included in InstrAlloc's instrument_options bitmask */
|
2009-12-14 23:57:48 -05:00
|
|
|
typedef enum InstrumentOption
|
|
|
|
|
{
|
2012-02-07 11:23:04 -05:00
|
|
|
INSTRUMENT_TIMER = 1 << 0, /* needs timer (and row counts) */
|
2010-02-25 21:01:40 -05:00
|
|
|
INSTRUMENT_BUFFERS = 1 << 1, /* needs buffer usage */
|
2012-02-07 11:23:04 -05:00
|
|
|
INSTRUMENT_ROWS = 1 << 2, /* needs row count */
|
2015-04-02 11:43:35 -04:00
|
|
|
INSTRUMENT_ALL = PG_INT32_MAX
|
2009-12-14 23:57:48 -05:00
|
|
|
} InstrumentOption;
|
|
|
|
|
|
2001-09-17 21:59:07 -04:00
|
|
|
typedef struct Instrumentation
|
|
|
|
|
{
|
2011-09-22 11:29:18 -04:00
|
|
|
/* Parameters set at node creation: */
|
2012-06-10 15:20:04 -04:00
|
|
|
bool need_timer; /* TRUE if we need timer data */
|
2011-09-22 11:29:18 -04:00
|
|
|
bool need_bufusage; /* TRUE if we need buffer usage data */
|
2001-09-17 21:59:07 -04:00
|
|
|
/* Info about current plan cycle: */
|
2001-10-25 01:50:21 -04:00
|
|
|
bool running; /* TRUE if we've completed first tuple */
|
2005-03-20 17:27:52 -05:00
|
|
|
instr_time starttime; /* Start time of current iteration of node */
|
2005-04-16 16:07:35 -04:00
|
|
|
instr_time counter; /* Accumulated runtime for this node */
|
2001-10-25 01:50:21 -04:00
|
|
|
double firsttuple; /* Time for first tuple of this cycle */
|
2005-04-16 16:07:35 -04:00
|
|
|
double tuplecount; /* Tuples emitted so far this cycle */
|
2010-02-25 21:01:40 -05:00
|
|
|
BufferUsage bufusage_start; /* Buffer usage at start */
|
2001-09-17 21:59:07 -04:00
|
|
|
/* Accumulated statistics across all completed cycles: */
|
2001-10-25 01:50:21 -04:00
|
|
|
double startup; /* Total startup time (in seconds) */
|
|
|
|
|
double total; /* Total total time (in seconds) */
|
|
|
|
|
double ntuples; /* Total tuples produced */
|
|
|
|
|
double nloops; /* # of run cycles for this node */
|
2011-09-22 11:29:18 -04:00
|
|
|
double nfiltered1; /* # tuples removed by scanqual or joinqual */
|
|
|
|
|
double nfiltered2; /* # tuples removed by "other" quals */
|
2010-02-25 21:01:40 -05:00
|
|
|
BufferUsage bufusage; /* Total buffer usage */
|
2001-09-17 21:59:07 -04:00
|
|
|
} Instrumentation;
|
|
|
|
|
|
2015-12-09 13:18:09 -05:00
|
|
|
typedef struct WorkerInstrumentation
|
|
|
|
|
{
|
|
|
|
|
int num_workers; /* # of structures that follow */
|
|
|
|
|
Instrumentation instrument[FLEXIBLE_ARRAY_MEMBER];
|
|
|
|
|
} WorkerInstrumentation;
|
|
|
|
|
|
2010-02-25 21:01:40 -05:00
|
|
|
extern PGDLLIMPORT BufferUsage pgBufferUsage;
|
2009-12-14 23:57:48 -05:00
|
|
|
|
|
|
|
|
extern Instrumentation *InstrAlloc(int n, int instrument_options);
|
2015-09-28 21:55:57 -04:00
|
|
|
extern void InstrInit(Instrumentation *instr, int instrument_options);
|
2001-09-17 21:59:07 -04:00
|
|
|
extern void InstrStartNode(Instrumentation *instr);
|
2006-05-30 10:01:58 -04:00
|
|
|
extern void InstrStopNode(Instrumentation *instr, double nTuples);
|
2001-09-17 21:59:07 -04:00
|
|
|
extern void InstrEndLoop(Instrumentation *instr);
|
2015-09-28 21:55:57 -04:00
|
|
|
extern void InstrAggNode(Instrumentation *dst, Instrumentation *add);
|
|
|
|
|
extern void InstrStartParallelQuery(void);
|
|
|
|
|
extern void InstrEndParallelQuery(BufferUsage *result);
|
|
|
|
|
extern void InstrAccumParallelQuery(BufferUsage *result);
|
2001-10-28 01:26:15 -05:00
|
|
|
|
2001-11-05 12:46:40 -05:00
|
|
|
#endif /* INSTRUMENT_H */
|