PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
instrument.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * instrument.h
4  * definitions for run-time statistics collection
5  *
6  *
7  * Copyright (c) 2001-2017, PostgreSQL Global Development Group
8  *
9  * src/include/executor/instrument.h
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef INSTRUMENT_H
14 #define INSTRUMENT_H
15 
16 #include "portability/instr_time.h"
17 
18 
19 typedef struct BufferUsage
20 {
21  long shared_blks_hit; /* # of shared buffer hits */
22  long shared_blks_read; /* # of shared disk blocks read */
23  long shared_blks_dirtied; /* # of shared blocks dirtied */
24  long shared_blks_written; /* # of shared disk blocks written */
25  long local_blks_hit; /* # of local buffer hits */
26  long local_blks_read; /* # of local disk blocks read */
27  long local_blks_dirtied; /* # of shared blocks dirtied */
28  long local_blks_written; /* # of local disk blocks written */
29  long temp_blks_read; /* # of temp blocks read */
30  long temp_blks_written; /* # of temp blocks written */
31  instr_time blk_read_time; /* time spent reading */
32  instr_time blk_write_time; /* time spent writing */
33 } BufferUsage;
34 
35 /* Flag bits included in InstrAlloc's instrument_options bitmask */
36 typedef enum InstrumentOption
37 {
38  INSTRUMENT_TIMER = 1 << 0, /* needs timer (and row counts) */
39  INSTRUMENT_BUFFERS = 1 << 1, /* needs buffer usage */
40  INSTRUMENT_ROWS = 1 << 2, /* needs row count */
43 
44 typedef struct Instrumentation
45 {
46  /* Parameters set at node creation: */
47  bool need_timer; /* TRUE if we need timer data */
48  bool need_bufusage; /* TRUE if we need buffer usage data */
49  /* Info about current plan cycle: */
50  bool running; /* TRUE if we've completed first tuple */
51  instr_time starttime; /* Start time of current iteration of node */
52  instr_time counter; /* Accumulated runtime for this node */
53  double firsttuple; /* Time for first tuple of this cycle */
54  double tuplecount; /* Tuples emitted so far this cycle */
55  BufferUsage bufusage_start; /* Buffer usage at start */
56  /* Accumulated statistics across all completed cycles: */
57  double startup; /* Total startup time (in seconds) */
58  double total; /* Total total time (in seconds) */
59  double ntuples; /* Total tuples produced */
60  double nloops; /* # of run cycles for this node */
61  double nfiltered1; /* # tuples removed by scanqual or joinqual */
62  double nfiltered2; /* # tuples removed by "other" quals */
63  BufferUsage bufusage; /* Total buffer usage */
65 
66 typedef struct WorkerInstrumentation
67 {
68  int num_workers; /* # of structures that follow */
69  Instrumentation instrument[FLEXIBLE_ARRAY_MEMBER];
71 
73 
74 extern Instrumentation *InstrAlloc(int n, int instrument_options);
75 extern void InstrInit(Instrumentation *instr, int instrument_options);
76 extern void InstrStartNode(Instrumentation *instr);
77 extern void InstrStopNode(Instrumentation *instr, double nTuples);
78 extern void InstrEndLoop(Instrumentation *instr);
79 extern void InstrAggNode(Instrumentation *dst, Instrumentation *add);
80 extern void InstrStartParallelQuery(void);
83 
84 #endif /* INSTRUMENT_H */
double nfiltered1
Definition: instrument.h:61
bool need_bufusage
Definition: instrument.h:48
long local_blks_hit
Definition: instrument.h:25
long local_blks_dirtied
Definition: instrument.h:27
long local_blks_read
Definition: instrument.h:26
void InstrEndLoop(Instrumentation *instr)
Definition: instrument.c:114
instr_time blk_read_time
Definition: instrument.h:31
struct timeval instr_time
Definition: instr_time.h:147
long shared_blks_read
Definition: instrument.h:22
double startup
Definition: instrument.h:57
void InstrStartParallelQuery(void)
Definition: instrument.c:170
void InstrInit(Instrumentation *instr, int instrument_options)
Definition: instrument.c:54
void InstrStartNode(Instrumentation *instr)
Definition: instrument.c:63
return result
Definition: formatting.c:1633
long temp_blks_written
Definition: instrument.h:30
PGDLLIMPORT BufferUsage pgBufferUsage
Definition: instrument.c:20
#define PGDLLIMPORT
Definition: c.h:1063
long shared_blks_written
Definition: instrument.h:24
BufferUsage bufusage_start
Definition: instrument.h:55
double firsttuple
Definition: instrument.h:53
double nfiltered2
Definition: instrument.h:62
InstrumentOption
Definition: instrument.h:36
void InstrEndParallelQuery(BufferUsage *result)
Definition: instrument.c:177
struct WorkerInstrumentation WorkerInstrumentation
instr_time starttime
Definition: instrument.h:51
long shared_blks_dirtied
Definition: instrument.h:23
double ntuples
Definition: instrument.h:59
long temp_blks_read
Definition: instrument.h:29
void InstrAggNode(Instrumentation *dst, Instrumentation *add)
Definition: instrument.c:143
double tuplecount
Definition: instrument.h:54
Instrumentation instrument[FLEXIBLE_ARRAY_MEMBER]
Definition: instrument.h:69
struct BufferUsage BufferUsage
BufferUsage bufusage
Definition: instrument.h:63
instr_time counter
Definition: instrument.h:52
void InstrAccumParallelQuery(BufferUsage *result)
Definition: instrument.c:185
instr_time blk_write_time
Definition: instrument.h:32
void InstrStopNode(Instrumentation *instr, double nTuples)
Definition: instrument.c:80
struct Instrumentation Instrumentation
Instrumentation * InstrAlloc(int n, int instrument_options)
Definition: instrument.c:30
long shared_blks_hit
Definition: instrument.h:21
#define PG_INT32_MAX
Definition: c.h:340
long local_blks_written
Definition: instrument.h:28