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