pgstats

package module
v2.0.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2019 License: MIT Imports: 9 Imported by: 2

README

pgstats

Documentation Go Report Card Coverage Status Build Status

pgstats provides convenient access to pg_stat_* statistics, allowing to monitor PostgreSQL instances inside go applications.

Install

go get github.com/vynaloze/pgstats

API reference

Check out the quick API overview or full documentation on godoc.org

Usage

Want it simple?
  1. Define your connection. You can do it anywhere, at any time and as many times as you want. However, you cannot override the settings once you define the connection. If you want to play with many connections, see the next section

    err := pgstats.DefineConnection("foo", "username", "password")
    
  2. Now you can collect statistics in any part of your code. If the connection has not been defined before, an error is returned.

    // pg_stat_bgwriter - returns single row
    b, _ := pgstats.PgStatBgWriter()
    fmt.Println(b.CheckpointsTimed)
    // Example result:
    // {446 true}
    
    // pg_stat_user_tables - returns many rows
    uts, _ := pgstats.PgStatUserTables()
    for _, ut := range uts {
       fmt.Printf("%s - seq_tup_read: %v\n", ut.Relname, ut.SeqTupRead.Int64)
    }
    // Example result:
    // foo - seq_tup_read: 9273
    // bar - seq_tup_read: 10
    
Want to have multiple connections?
  1. Define them. If you want to free the connection pool after you are done (and you are not exiting your application right away), you can close the connection with Close() method.

    connFoo, _ := pgstats.Connect("foo", "username", "password")
    defer connFoo.Close()
    connBar, _ := pgstats.Connect("bar", "username", "password")
    defer connBar.Close()
    
  2. Use them.

    // Query both connections
    utf, _ := connFoo.PgStatUserTables()
    utb, _ := connBar.PgStatUserTables()
    // Print first entries in pg_stat_user_tables for both databases
    fmt.Printf("foo: %s - seq_tup_read: %v\n", utf[0].Relname, utf[0].SeqTupRead)
    fmt.Printf("bar: %s - seq_tup_read: %v\n", utb[0].Relname, utb[0].SeqTupRead)
    // foo: example - seq_tup_read: 9273
    // bar: test - seq_tup_read: 10
    
Want to specify optional connection parameters?

No problem - use functional options:

err := pgstats.DefineConnection("foo", "username", "password", pgstats.Host("10.0.1.3"), pgstats.Port(6432))
conn, err := pgstats.Connect("foo", "username", "password", pgstats.SslMode("disable"))

Full reference

Supported PostgreSQL versions

  • 11
  • 10
  • 9.6
  • 9.5
  • 9.4

License

The library is licensed under the MIT License.

Documentation

Overview

Package pgstats provides convenient access to all pg_stat_* statistics, allowing to monitor PostgreSQL instances inside go applications.

For details, see: https://github.com/vynaloze/pgstats/blob/master/README.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefineConnection added in v1.0.0

func DefineConnection(dbname string, user string, password string, options ...Option) error

DefineConnection defines the connection, which can be later used globally to collect statistics.

Types

type Option

type Option func(*connection) error

Option represents an optional connection parameter

func ConnectTimeout

func ConnectTimeout(seconds int) Option

ConnectTimeout sets the maximum wait for connection, in seconds. Zero or not specified means wait indefinitely.

func FallbackApplicationName

func FallbackApplicationName(name string) Option

FallbackApplicationName sets an application_name to fall back to if one isn't provided.

func Host

func Host(host string) Option

Host sets the host to connect to. Values that start with / are for unix domain sockets.

Default: localhost

func Port

func Port(port int) Option

Port sets the port to bind to.

Default: 5432

func SslCert

func SslCert(location string) Option

SslCert sets the location of the certificate file. The file must contain PEM encoded data.

func SslKey

func SslKey(location string) Option

SslKey sets the key file location. The file must contain PEM encoded data.

func SslMode

func SslMode(mode string) Option

SslMode sets whether or not to use SSL. Valid values for sslmode are:

disable - No SSL
require - Always SSL (skip verification)
verify-ca - Always SSL (verify that the certificate presented by the server was signed by a trusted CA)
verify-full - Always SSL (verify that the certification presented by the server was signed by a trusted CA and the server host name matches the one in the certificate)

Default: require

func SslRootCert

func SslRootCert(location string) Option

SslRootCert sets the location of the root certificate file. The file must contain PEM encoded data.

type PgStatActivityRow

type PgStatActivityRow struct {
	// OID of the database this backend is connected to
	Datid nullable.Int64 `json:"datid"`
	// Name of the database this backend is connected to
	Datname nullable.String `json:"datname"`
	// Process ID of this backend
	Pid int64 `json:"pid"`
	// OID of the user logged into this backend
	Usesysid nullable.Int64 `json:"usesysid"`
	// Name of the user logged into this backend
	Usename nullable.String `json:"usename"`
	// Name of the application that is connected to this backend
	ApplicationName nullable.String `json:"application_name"`
	// IP address of the client connected to this backend.
	// If this field is null, it indicates either that the client is connected via a Unix socket on the server machine
	// or that this is an internal process such as autovacuum.
	ClientAddr nullable.String `json:"client_addr"`
	// Host name of the connected client, as reported by a reverse DNS lookup of client_addr.
	// This field will only be non-null for IP connections, and only when log_hostname is enabled.
	ClientHostname nullable.String `json:"client_hostname"`
	// TCP port number that the client is using for communication with this backend,
	// or -1 if a Unix socket is used
	ClientPort nullable.Int64 `json:"client_port"`
	// Time when this process was started.
	// For client backends, this is the time the client connected to the server.
	BackendStart nullable.Time `json:"backend_start"`
	// Time when this process' current transaction was started,
	// or null if no transaction is active.
	// If the current query is the first of its transaction, this column is equal to the query_start column.
	XactStart nullable.Time `json:"xact_start"`
	// Time when the currently active query was started,
	// or if state is not active, when the last query was started
	QueryStart nullable.Time `json:"query_start"`
	// ime when the state was last changed
	StateChange nullable.Time `json:"state_change"`
	// The type of event for which the backend is waiting, if any; otherwise NULL.
	// Supported since PostgreSQL 9.6.
	// For possible values, see:
	// https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW
	WaitEventType nullable.String `json:"wait_event_type"`
	// Wait event name if backend is currently waiting, otherwise NULL.
	// Supported since PostgreSQL 9.6.
	// For details, see:
	// https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE
	WaitEvent nullable.String `json:"wait_event"`
	// True if this backend is currently waiting on a lock.
	// Supported until PostgreSQL 9.5 (inclusive).
	Waiting nullable.Bool `json:"waiting"`
	// Current overall state of this backend.
	// For possible values, see:
	// https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW
	State nullable.String `json:"state"`
	// Top-level transaction identifier of this backend, if any.
	BackendXid nullable.Int64 `json:"backend_xid"`
	// The current backend's xmin horizon.
	BackendXmin nullable.Int64 `json:"backend_xmin"`
	// Text of this backend's most recent query.
	// If state is active this field shows the currently executing query.
	// In all other states, it shows the last query that was executed.
	// By default the query text is truncated at 1024 characters;
	// this value can be changed via the parameter track_activity_query_size.
	Query nullable.String `json:"query"`
	// Type of current backend.
	// Possible types are autovacuum launcher, autovacuum worker, logical replication launcher,
	// logical replication worker, parallel worker, background writer, client backend, checkpointer,
	// startup, walreceiver, walsender and walwriter.
	// In addition, background workers registered by extensions may have additional types.
	// Supported since PostgreSQL 10
	BackendType nullable.String `json:"backend_type"`
}

PgStatActivityRow represents schema of pg_stat_activity view

type PgStatActivityView

type PgStatActivityView []PgStatActivityRow

PgStatActivityView represents content of pg_stat_activity view

func PgStatActivity added in v1.0.0

func PgStatActivity() (PgStatActivityView, error)

PgStatActivity returns a slice, containing information related to the current activity of a process, such as state and current query, for each server process.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW

type PgStatAllIndexesView

type PgStatAllIndexesView []PgStatIndexesRow

PgStatAllIndexesView represents content of pg_stat_all_indexes view

func PgStatAllIndexes added in v1.0.0

func PgStatAllIndexes() (PgStatAllIndexesView, error)

PgStatAllIndexes returns a slice containing statistics about accesses to each index in the current database.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ALL-INDEXES-VIEW

type PgStatAllTablesView

type PgStatAllTablesView []PgStatTablesRow

PgStatAllTablesView represents content of pg_stat_all_tables view

func PgStatAllTables added in v1.0.0

func PgStatAllTables() (PgStatAllTablesView, error)

PgStatAllTables returns a slice containing statistics about accesses to each table in the current database (including TOAST tables).

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ALL-TABLES-VIEW

type PgStatArchiverView

type PgStatArchiverView struct {
	// Number of WAL files that have been successfully archived
	ArchivedCount nullable.Int64 `json:"archived_count"`
	// Name of the last WAL file successfully archived
	LastArchivedWal nullable.String `json:"last_archived_wal"`
	// Time of the last successful archive operation
	LastArchivedTime nullable.Time `json:"last_archived_time"`
	// Number of failed attempts for archiving WAL files
	FailedCount nullable.Int64 `json:"failed_count"`
	// Name of the WAL file of the last failed archival operation
	LastFailedWal nullable.String `json:"last_failed_wal"`
	// Time of the last failed archival operation
	LastFailedTime nullable.Time `json:"last_failed_time"`
	// Time at which these statistics were last reset
	StatsReset nullable.Time `json:"stats_reset"`
}

PgStatArchiverView represents content of pg_stat_archiver view

func PgStatArchiver added in v1.0.0

func PgStatArchiver() (PgStatArchiverView, error)

PgStatArchiver returns a single struct, containing global data for the cluster, showing statistics about the WAL archiver process's activity.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ARCHIVER-VIEW

type PgStatBgWriterView

type PgStatBgWriterView struct {
	// Number of scheduled checkpoints that have been performed
	CheckpointsTimed nullable.Int64 `json:"checkpoints_timed"`
	// Number of requested checkpoints that have been performed
	CheckpointsReq nullable.Int64 `json:"checkpoints_req"`
	// Total amount of time that has been spent in the portion of checkpoint processing
	// where files are written to disk, in milliseconds
	CheckpointWriteTime nullable.Float64 `json:"checkpoint_write_time"`
	// Total amount of time that has been spent in the portion of checkpoint processing
	// where files are synchronized to disk, in milliseconds
	CheckpointSyncTime nullable.Float64 `json:"checkpoint_sync_time"`
	// Number of buffers written during checkpoints
	BuffersCheckpoint nullable.Int64 `json:"buffers_checkpoint"`
	// Number of buffers written by the background writer
	BuffersClean nullable.Int64 `json:"buffers_clean"`
	// Number of times the background writer stopped a cleaning scan because it had written too many buffers
	MaxWrittenClean nullable.Int64 `json:"maxwritten_clean"`
	// Number of buffers written directly by a backend
	BuffersBackend nullable.Int64 `json:"buffers_backend"`
	// Number of times a backend had to execute its own fsync call
	// (normally the background writer handles those even when the backend does its own write)
	BuffersBackendFsync nullable.Int64 `json:"buffers_backend_fsync"`
	// Number of buffers allocated
	BuffersAlloc nullable.Int64 `json:"buffers_alloc"`
	// Time at which these statistics were last reset
	StatsReset nullable.Time `json:"stats_reset"`
}

PgStatBgWriterView represents content of pg_stat_bgwriter view

func PgStatBgWriter added in v1.0.0

func PgStatBgWriter() (PgStatBgWriterView, error)

PgStatBgWriter returns a single struct, containing global data for the cluster, showing statistics about the background writer process's activity.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW

type PgStatDatabaseConflictsRow

type PgStatDatabaseConflictsRow struct {
	// OID of a database
	Datid int64 `json:"datid"`
	// Name of this database
	Datname string `json:"datname"`
	// Number of queries in this database that have been canceled due to dropped tablespaces
	ConflTablespace nullable.Int64 `json:"confl_tablespace"`
	// Number of queries in this database that have been canceled due to lock timeouts
	ConflLock nullable.Int64 `json:"confl_lock"`
	// Number of queries in this database that have been canceled due to old snapshots
	ConflSnapshot nullable.Int64 `json:"confl_snapshot"`
	// Number of queries in this database that have been canceled due to pinned buffers
	ConflBufferpin nullable.Int64 `json:"confl_bufferpin"`
	// Number of queries in this database that have been canceled due to deadlocks
	ConflDeadlock nullable.Int64 `json:"confl_deadlock"`
}

PgStatDatabaseConflictsRow represents schema of pg_stat_database_conflicts view

type PgStatDatabaseConflictsView

type PgStatDatabaseConflictsView []PgStatDatabaseConflictsRow

PgStatDatabaseConflictsView represents content of pg_stat_database_conflicts view

func PgStatDatabaseConflicts added in v1.0.0

func PgStatDatabaseConflicts() (PgStatDatabaseConflictsView, error)

PgStatDatabaseConflicts returns a slice containing database-wide statistics for each database in the cluster about query cancels occurring due to conflicts with recovery on standby servers. This will only contain information on standby servers, since conflicts do not occur on master servers.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-CONFLICTS-VIEW

type PgStatDatabaseRow

type PgStatDatabaseRow struct {
	// OID of a database
	Datid int64 `json:"datid"`
	// Name of this database
	Datname string `json:"datname"`
	// Number of backends currently connected to this database.
	// This is the only column in this view that returns a value reflecting current state;
	// all other columns return the accumulated values since the last reset.
	NumBackends int64 `json:"numbackends"`
	// Number of transactions in this database that have been committed
	XactCommit nullable.Int64 `json:"xact_commit"`
	//	Number of transactions in this database that have been rolled back
	XactRollback nullable.Int64 `json:"xact_rollback"`
	// Number of disk blocks read in this database
	BlksRead nullable.Int64 `json:"blks_read"`
	// Number of times disk blocks were found already in the buffer cache, so that a read was not necessary
	// (this only includes hits in the PostgreSQL buffer cache, not the operating system's file system cache)
	BlksHit nullable.Int64 `json:"blks_hit"`
	// Number of rows returned by queries in this database
	TupReturned nullable.Int64 `json:"tup_returned"`
	// Number of rows fetched by queries in this database
	TupFetched nullable.Int64 `json:"tup_fetched"`
	// Number of rows inserted by queries in this database
	TupInserted nullable.Int64 `json:"tup_inserted"`
	// Number of rows updated by queries in this database
	TupUpdated nullable.Int64 `json:"tup_updated"`
	// 	Number of rows deleted by queries in this database
	TupDeleted nullable.Int64 `json:"tup_deleted"`
	// Number of queries canceled due to conflicts with recovery in this database.
	// (Conflicts occur only on standby servers; see pg_stat_database_conflicts for details.)
	Conflicts nullable.Int64 `json:"conflicts"`
	// Number of temporary files created by queries in this database.
	// All temporary files are counted,
	// regardless of why the temporary file was created (e.g., sorting or hashing),
	// and regardless of the log_temp_files setting.
	TempFiles nullable.Int64 `json:"temp_files"`
	// Total amount of data written to temporary files by queries in this database.
	// All temporary files are counted,
	// regardless of why the temporary file was created,
	// and regardless of the log_temp_files setting.
	TempBytes nullable.Int64 `json:"temp_bytes"`
	// Number of deadlocks detected in this database
	Deadlocks nullable.Int64 `json:"deadlocks"`
	// Time spent reading data file blocks by backends in this database, in milliseconds
	BlkReadTime nullable.Float64 `json:"blk_read_time"`
	// Time spent writing data file blocks by backends in this database, in milliseconds
	BlkWriteTime nullable.Float64 `json:"blk_write_time"`
	// Time at which these statistics were last reset
	StatsReset nullable.Time `json:"stats_reset"`
}

PgStatDatabaseRow represents schema of pg_stat_database view

type PgStatDatabaseView

type PgStatDatabaseView []PgStatDatabaseRow

PgStatDatabaseView represents content of pg_stat_database view

func PgStatDatabase added in v1.0.0

func PgStatDatabase() (PgStatDatabaseView, error)

PgStatDatabase returns a slice containing database-wide statistics for each database in the cluster.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW

type PgStatFunctionsRow

type PgStatFunctionsRow struct {
	// OID of a function
	Funcid int64 `json:"funcid"`
	// Name of the schema this function is in
	Schemaname string `json:"schemaname"`
	// Name of this function
	Funcname string `json:"funcname"`
	// Number of times this function has been called
	Calls nullable.Int64 `json:"calls"`
	// Total time spent in this function and all other functions called by it, in milliseconds
	TotalTime nullable.Float64 `json:"total_time"`
	// Total time spent in this function itself, not including other functions called by it, in milliseconds
	SelfTime nullable.Float64 `json:"self_time"`
}

PgStatFunctionsRow represents schema of pg_stat*_user_functions views

type PgStatIndexesRow

type PgStatIndexesRow struct {
	// OID of the table for this index
	Relid int64 `json:"relid"`
	// OID of this index
	Indexrelid int64 `json:"indexrelid"`
	// Name of the schema this index is in
	Schemaname string `json:"schemaname"`
	// Name of the table for this index
	Relname string `json:"relname"`
	// Name of this index
	Indexrelname string `json:"indexrelname"`
	// Number of index scans initiated on this index
	IdxScan nullable.Int64 `json:"idx_scan"`
	// Number of index entries returned by scans on this index
	IdxTupRead nullable.Int64 `json:"idx_tup_read"`
	// Number of live table rows fetched by simple index scans using this index
	IdxTupFetch nullable.Int64 `json:"idx_tup_fetch"`
}

PgStatIndexesRow represents schema of pg_stat_*_indexes views

type PgStatIoAllIndexesView

type PgStatIoAllIndexesView []PgStatIoIndexesRow

PgStatIoAllIndexesView represents content of pg_statio_all_indexes view

func PgStatIoAllIndexes added in v1.0.0

func PgStatIoAllIndexes() (PgStatIoAllIndexesView, error)

PgStatIoAllIndexes returns a slice containing statistics about I/O on each index in the current database.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STATIO-ALL-INDEXES-VIEW

type PgStatIoAllSequencesView

type PgStatIoAllSequencesView []PgStatIoSequencesRow

PgStatIoAllSequencesView represents content of pg_statio_all_sequences view

func PgStatIoAllSequences added in v1.0.0

func PgStatIoAllSequences() (PgStatIoAllSequencesView, error)

PgStatIoAllSequences returns a slice containing statistics about I/O on each sequence in the current database.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STATIO-ALL-SEQUENCES-VIEW

type PgStatIoAllTablesView

type PgStatIoAllTablesView []PgStatIoTablesRow

PgStatIoAllTablesView represents content of pg_statio_all_tables view

func PgStatIoAllTables added in v1.0.0

func PgStatIoAllTables() (PgStatIoAllTablesView, error)

PgStatIoAllTables returns a slice containing statistics about I/O on each table in the current database (including TOAST tables).

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STATIO-ALL-TABLES-VIEW

type PgStatIoIndexesRow

type PgStatIoIndexesRow struct {
	// OID of the table for this index
	Relid int64 `json:"relid"`
	// OID of this index
	Indexrelid int64 `json:"indexrelid"`
	// Name of the schema this index is in
	Schemaname string `json:"schemaname"`
	// Name of the table for this index
	Relname string `json:"relname"`
	// Name of this index
	Indexrelname string `json:"indexrelname"`
	// Number of disk blocks read from this index
	IdxBlksRead nullable.Int64 `json:"idx_blks_read"`
	// Number of buffer hits in this index
	IdxBlksHit nullable.Int64 `json:"idx_blks_hit"`
}

PgStatIoIndexesRow represents schema of pg_statio_*_indexes views

type PgStatIoSequencesRow

type PgStatIoSequencesRow struct {
	// OID of a sequence
	Relid int64 `json:"relid"`
	// Name of the schema this sequence is in
	Schemaname string `json:"schemaname"`
	// Name of this sequence
	Relname string `json:"relname"`
	// Number of disk blocks read from this sequence
	BlksRead nullable.Int64 `json:"blks_read"`
	// Number of buffer hits in this sequence
	BlksHit nullable.Int64 `json:"blks_hit"`
}

PgStatIoSequencesRow represents schema of pg_statio_*_sequences views

type PgStatIoSystemIndexesView

type PgStatIoSystemIndexesView []PgStatIoIndexesRow

PgStatIoSystemIndexesView represents content of pg_statio_system_indexes view

func PgStatIoSystemIndexes added in v1.0.0

func PgStatIoSystemIndexes() (PgStatIoSystemIndexesView, error)

PgStatIoSystemIndexes returns a slice containing statistics about I/O on each system index in the current database.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STATIO-ALL-INDEXES-VIEW

type PgStatIoSystemSequencesView

type PgStatIoSystemSequencesView []PgStatIoSequencesRow

PgStatIoSystemSequencesView represents content of pg_statio_system_sequences view

func PgStatIoSystemSequences added in v1.0.0

func PgStatIoSystemSequences() (PgStatIoSystemSequencesView, error)

PgStatIoSystemSequences returns a slice containing statistics about I/O on each system sequence in the current database. (As of PostgreSQL 11, no system sequences are defined, so this view is always empty.)

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STATIO-ALL-SEQUENCES-VIEW

type PgStatIoSystemTablesView

type PgStatIoSystemTablesView []PgStatIoTablesRow

PgStatIoSystemTablesView represents content of pg_statio_system_tables view

func PgStatIoSystemTables added in v1.0.0

func PgStatIoSystemTables() (PgStatIoSystemTablesView, error)

PgStatIoSystemTables returns a slice containing statistics about I/O on each system table in the current database (including TOAST tables).

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STATIO-ALL-TABLES-VIEW

type PgStatIoTablesRow

type PgStatIoTablesRow struct {
	// OID of a table
	Relid int64 `json:"relid"`
	// Name of the schema that this table is in
	Schemaname string `json:"schemaname"`
	// Name of this table
	Relname string `json:"relname"`
	// Number of disk blocks read from this table
	HeapBlksRead nullable.Int64 `json:"heap_blks_read"`
	// Number of buffer hits in this table
	HeapBlksHit nullable.Int64 `json:"heap_blks_hit"`
	// Number of disk blocks read from all indexes on this table
	IdxBlksRead nullable.Int64 `json:"idx_blks_read"`
	// Number of buffer hits in all indexes on this table
	IdxBlksHit nullable.Int64 `json:"idx_blks_hit"`
	// Number of disk blocks read from this table's TOAST table (if any)
	ToastBlksRead nullable.Int64 `json:"toast_blks_read"`
	// Number of buffer hits in this table's TOAST table (if any)
	ToastBlksHit nullable.Int64 `json:"toast_blks_hit"`
	// Number of disk blocks read from this table's TOAST table indexes (if any)
	TidxBlksRead nullable.Int64 `json:"tidx_blks_read"`
	// Number of buffer hits in this table's TOAST table indexes (if any)
	TidxBlksHit nullable.Int64 `json:"tidx_blks_hit"`
}

PgStatIoTablesRow represents schema of pg_statio_*_tables views

type PgStatIoUserIndexesView

type PgStatIoUserIndexesView []PgStatIoIndexesRow

PgStatIoUserIndexesView represents content of pg_statio_user_indexes view

func PgStatIoUserIndexes added in v1.0.0

func PgStatIoUserIndexes() (PgStatIoUserIndexesView, error)

PgStatIoUserIndexes returns a slice containing statistics about I/O on each user-defined index in the current database.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STATIO-ALL-INDEXES-VIEW

type PgStatIoUserSequencesView

type PgStatIoUserSequencesView []PgStatIoSequencesRow

PgStatIoUserSequencesView represents content of pg_statio_user_sequences view

func PgStatIoUserSequences added in v1.0.0

func PgStatIoUserSequences() (PgStatIoUserSequencesView, error)

PgStatIoUserSequences returns a slice containing statistics about I/O on each user-defined sequence in the current database.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STATIO-ALL-SEQUENCES-VIEW

type PgStatIoUserTablesView

type PgStatIoUserTablesView []PgStatIoTablesRow

PgStatIoUserTablesView represents content of pg_statio_user_tables view

func PgStatIoUserTables added in v1.0.0

func PgStatIoUserTables() (PgStatIoUserTablesView, error)

PgStatIoUserTables returns a slice containing statistics about I/O on each user-defined table in the current database (including TOAST tables).

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STATIO-ALL-TABLES-VIEW

type PgStatProgressVacuumRow

type PgStatProgressVacuumRow struct {
	// Process ID of backend.
	Pid int64 `json:"pid"`
	// OID of the database to which this backend is connected.
	Datid int64 `json:"datid"`
	// Name of the database to which this backend is connected.
	Datname string `json:"datname"`
	// OID of the table being vacuumed.
	Relid int64 `json:"relid"`
	// Current processing phase of vacuum. See:
	// https://www.postgresql.org/docs/current/progress-reporting.html#VACUUM-PHASES
	Phase string `json:"phase"`
	// Total number of heap blocks in the table. This number is reported as of the beginning of the scan;
	// blocks added later will not be (and need not be) visited by this VACUUM.
	HeapBlksTotal nullable.Int64 `json:"heap_blks_total"`
	// Number of heap blocks scanned.
	// Because the visibility map is used to optimize scans, some blocks will be skipped without inspection;
	// skipped blocks are included in this total, so that this number will eventually become equal to heap_blks_total
	// when the vacuum is complete. This counter only advances when the phase is scanning heap.
	HeapBlksScanned nullable.Int64 `json:"heap_blks_scanned"`
	// Number of heap blocks vacuumed. Unless the table has no indexes, this counter only advances when the phase is vacuuming heap.
	// Blocks that contain no dead tuples are skipped, so the counter may sometimes skip forward in large increments.
	HeapBlksVacuumed nullable.Int64 `json:"heap_blks_vacuumed"`
	// Number of completed index vacuum cycles.
	IndexVacuumCount nullable.Int64 `json:"index_vacuum_count"`
	// Number of dead tuples that we can store before needing to perform an index vacuum cycle, based on maintenance_work_mem.
	MaxDeadTuples nullable.Int64 `json:"max_dead_tuples"`
	// Number of dead tuples collected since the last index vacuum cycle.
	NumDeadTuples nullable.Int64 `json:"num_dead_tuples"`
}

PgStatProgressVacuumRow represents schema of pg_stat_progress_vacuum view

type PgStatProgressVacuumView

type PgStatProgressVacuumView []PgStatProgressVacuumRow

PgStatProgressVacuumView represents content of pg_stat_progress_vacuum view

func PgStatProgressVacuum added in v1.0.0

func PgStatProgressVacuum() (PgStatProgressVacuumView, error)

PgStatProgressVacuum returns a slice, containing information related to currently running VACUUM processes, for each backend (including autovacuum worker processes) that is currently vacuuming. Progress reporting is not currently supported for VACUUM FULL and backends running VACUUM FULL will not be listed in this view.

Supported since PostgreSQL 9.6.

For more details, see: https://www.postgresql.org/docs/current/progress-reporting.html#VACUUM-PROGRESS-REPORTING

type PgStatReplicationRow added in v0.2.0

type PgStatReplicationRow struct {
	// Process ID of a WAL sender process
	Pid int64 `json:"pid"`
	// OID of the user logged into this WAL sender process
	Usesysid nullable.Int64 `json:"usesysid"`
	// Name of the user logged into this WAL sender process
	Usename nullable.String `json:"usename"`
	// Name of the application that is connected to this WAL sender
	ApplicationName nullable.String `json:"application_name"`
	// IP address of the client connected to this WAL sender.
	// If this field is null, it indicates that the client is connected via a Unix socket on the server machine.
	ClientAddr nullable.String `json:"client_addr"`
	// Host name of the connected client, as reported by a reverse DNS lookup of client_addr.
	// This field will only be non-null for IP connections, and only when log_hostname is enabled.
	ClientHostname nullable.String `json:"client_hostname"`
	// TCP port number that the client is using for communication with this WAL sender, or -1 if a Unix socket is used
	ClientPort nullable.Int64 `json:"client_port"`
	// Time when this process was started, i.e., when the client connected to this WAL sender
	BackendStart nullable.Time `json:"backend_start"`
	// This standby's xmin horizon reported by hot_standby_feedback - see:
	// https://www.postgresql.org/docs/current/runtime-config-replication.html#GUC-HOT-STANDBY-FEEDBACK
	BackendXmin nullable.Int64 `json:"backend_xmin"`
	// Current WAL sender state.
	// For possible values, see:
	// https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-REPLICATION-VIEW
	State nullable.String `json:"state"`
	// Last write-ahead log location sent on this connection
	SentLsn nullable.Int64 `json:"sent_lsn"`
	// Last write-ahead log location written to disk by this standby server
	WriteLsn nullable.Int64 `json:"write_lsn"`
	// Last write-ahead log location flushed to disk by this standby server
	FlushLsn nullable.Int64 `json:"flush_lsn"`
	// Last write-ahead log location replayed into the database on this standby server
	ReplayLsn nullable.Int64 `json:"replay_lsn"`
	// Time elapsed between flushing recent WAL locally and receiving notification that this standby server
	// has written it (but not yet flushed it or applied it). This can be used to gauge the delay
	// that synchronous_commit level remote_write incurred while committing
	// if this server was configured as a synchronous standby.
	// Supported since PostgreSQL 10
	WriteLag nullable.Time `json:"write_lag"`
	// Time elapsed between flushing recent WAL locally and receiving notification that this standby server
	// has written 	// and flushed it (but not yet applied it). This can be used to gauge the delay
	// that synchronous_commit level on incurred while committing
	// if this server was configured as a synchronous standby.
	// Supported since PostgreSQL 10
	FlushLag nullable.Time `json:"flush_lag"`
	// Time elapsed between flushing recent WAL locally and receiving notification that this standby server
	// has written, flushed and applied it. This can be used to gauge the delay
	// that synchronous_commit level remote_apply incurred while committing
	// if this server was configured as a synchronous standby.
	// Supported since PostgreSQL 10
	ReplayLag nullable.Time `json:"replay_lag"`
	// Priority of this standby server for being chosen as the synchronous standby
	// in a priority-based synchronous replication. This has no effect in a quorum-based synchronous replication.
	SyncPriority nullable.Int64 `json:"sync_priority"`
	// Synchronous state of this standby server.
	// For possible values, see:
	// https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-REPLICATION-VIEW
	SyncState nullable.String `json:"sync_state"`
}

PgStatReplicationRow represents schema of pg_stat_replication view

type PgStatReplicationView added in v0.2.0

type PgStatReplicationView []PgStatReplicationRow

PgStatReplicationView represents content of pg_stat_replication view

func PgStatReplication added in v1.0.0

func PgStatReplication() (PgStatReplicationView, error)

PgStatReplication returns a slice, containing statistics about each WAL sender process, showing information about replication to that sender's connected standby server.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-REPLICATION-VIEW

type PgStatSslRow

type PgStatSslRow struct {
	// Process ID of a backend or WAL sender process
	Pid int64 `json:"pid"`
	// True if SSL is used on this connection
	Ssl bool `json:"ssl"`
	// Version of SSL in use, or NULL if SSL is not in use on this connection
	Version nullable.String `json:"version"`
	// Name of SSL cipher in use, or NULL if SSL is not in use on this connection
	Cipher nullable.String `json:"cipher"`
	// Number of bits in the encryption algorithm used, or NULL if SSL is not used on this connection
	Bits nullable.Int64 `json:"bits"`
	// True if SSL compression is in use, false if not, or NULL if SSL is not in use on this connection
	Compression nullable.Bool `json:"compression"`
	// Distinguished Name (DN) field from the client certificate used,
	// or NULL if no client certificate was supplied or if SSL is not in use on this connection.
	// This field is truncated if the DN field is longer than NAMEDATALEN (64 characters in a standard build)
	Clientdn nullable.String `json:"clientdn"`
}

PgStatSslRow represents schema of pg_stat_ssl view

type PgStatSslView

type PgStatSslView []PgStatSslRow

PgStatSslView represents content of pg_stat_ssl view

func PgStatSsl added in v1.0.0

func PgStatSsl() (PgStatSslView, error)

PgStatSsl returns a slice, containing statistics about SSL usage on the connection for each backend or WAL sender process.

Supported since PostgreSQL 9.5.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-SSL

type PgStatStatementsRow added in v0.2.0

type PgStatStatementsRow struct {
	// OID of user who executed the statement
	Userid int64 `json:"userid"`
	// OID of database in which the statement was executed
	Dbid int64 `json:"dbid"`
	// Internal hash code, computed from the statement's parse tree
	Queryid int64 `json:"queryid"`
	// Text of a representative statement
	Query string `json:"query"`
	// Number of times executed
	Calls int64 `json:"calls"`
	// Total time spent in the statement, in milliseconds
	// Supported since PostgreSQL 9.5
	TotalTime float64 `json:"total_time"`
	// Minimum time spent in the statement, in milliseconds
	// Supported since PostgreSQL 9.5
	MinTime float64 `json:"min_time"`
	// Maximum time spent in the statement, in milliseconds
	// Supported since PostgreSQL 9.5
	MaxTime float64 `json:"max_time"`
	// Mean time spent in the statement, in milliseconds
	// Supported since PostgreSQL 9.5
	MeanTime float64 `json:"mean_time"`
	// Population standard deviation of time spent in the statement, in milliseconds
	// Supported since PostgreSQL 9.5
	StddevTime float64 `json:"stddev_time"`
	// Total number of rows retrieved or affected by the statement
	Rows int64 `json:"rows"`
	// Total number of shared block cache hits by the statement
	SharedBlksHit int64 `json:"shared_blks_hit"`
	// Total number of shared blocks read by the statement
	SharedBlksRead int64 `json:"shared_blks_read"`
	// Total number of shared blocks dirtied by the statement
	SharedBlksDirtied int64 `json:"shared_blks_dirtied"`
	// Total number of shared blocks written by the statement
	SharedBlksWritten int64 `json:"shared_blks_written"`
	// Total number of local block cache hits by the statement
	LocalBlksHit int64 `json:"local_blks_hit"`
	// Total number of local blocks read by the statement
	LocalBlksRead int64 `json:"local_blks_read"`
	// Total number of local blocks dirtied by the statement
	LocalBlksDirtied int64 `json:"local_blks_dirtied"`
	// Total number of local blocks written by the statement
	LocalBlksWritten int64 `json:"local_blks_written"`
	// Total number of temp blocks read by the statement
	TempBlksRead int64 `json:"temp_blks_read"`
	// Total number of temp blocks written by the statement
	TempBlksWritten int64 `json:"temp_blks_written"`
	// Total time the statement spent reading blocks, in milliseconds (if track_io_timing is enabled, otherwise zero)
	BlkReadTime float64 `json:"blk_read_time"`
	// Total time the statement spent writing blocks, in milliseconds (if track_io_timing is enabled, otherwise zero)
	BlkWriteTime float64 `json:"blk_write_time"`
}

PgStatStatementsRow represents schema of pg_stat_statements view

type PgStatStatementsView added in v0.2.0

type PgStatStatementsView []PgStatStatementsRow

PgStatStatementsView represents content of pg_stat_statements view

func PgStatStatements added in v1.0.0

func PgStatStatements() (PgStatStatementsView, error)

PgStatStatements returns a slice containing statistics about executions of all SQL statements in the current database.

For more details, see: https://www.postgresql.org/docs/current/pgstatstatements.html

type PgStatSubscriptionRow added in v0.2.0

type PgStatSubscriptionRow struct {
	// OID of the subscription
	Subid nullable.Int64 `json:"subid"`
	// Name of the subscription
	Subname nullable.String `json:"subname"`
	// Process ID of the subscription worker process
	Pid nullable.Int64 `json:"pid"`
	// OID of the relation that the worker is synchronizing; null for the main apply worker
	Relid nullable.Int64 `json:"relid"`
	// Last write-ahead log location received, the initial value of this field being 0
	ReceivedLsn nullable.Int64 `json:"received_lsn"`
	// Send time of last message received from origin WAL sender
	LastMsgSendTime nullable.Time `json:"last_msg_send_time"`
	// Receipt time of last message received from origin WAL sender
	LastMsgReceiptTime nullable.Time `json:"last_msg_receipt_time"`
	// Last write-ahead log location reported to origin WAL sender
	LatestEndLsn nullable.Int64 `json:"latest_end_lsn"`
	// Time of last write-ahead log location reported to origin WAL sender
	LatestEndTime nullable.Time `json:"latest_end_time"`
}

PgStatSubscriptionRow reprowents schema of pg_stat_subscription view

type PgStatSubscriptionView added in v0.2.0

type PgStatSubscriptionView []PgStatSubscriptionRow

PgStatSubscriptionView reprowents content of pg_stat_subscription view

func PgStatSubscription added in v1.0.0

func PgStatSubscription() (PgStatSubscriptionView, error)

PgStatSubscription returns a slice, containing statistics about subscription for main worker (with null PID if the worker is not running), and workers handling the initial data copy of the subscribed tables.

Supported since PostgreSQL 10.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-SUBSCRIPTION

type PgStatSystemIndexesView

type PgStatSystemIndexesView []PgStatIndexesRow

PgStatSystemIndexesView represents content of pg_stat_system_indexes view

func PgStatSystemIndexes added in v1.0.0

func PgStatSystemIndexes() (PgStatSystemIndexesView, error)

PgStatSystemIndexes returns a slice containing statistics about accesses to each system index in the current database.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ALL-INDEXES-VIEW

type PgStatSystemTablesView

type PgStatSystemTablesView []PgStatTablesRow

PgStatSystemTablesView represents content of pg_stat_system_tables view

func PgStatSystemTables added in v1.0.0

func PgStatSystemTables() (PgStatSystemTablesView, error)

PgStatSystemTables returns a slice containing statistics about accesses to each system table in the current database (including TOAST tables).

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ALL-TABLES-VIEW

type PgStatTablesRow

type PgStatTablesRow struct {
	// OID of a table
	Relid int64 `json:"relid"`
	// Name of the schema that this table is in
	Schemaname string `json:"schemaname"`
	// Name of this table
	Relname string `json:"relname"`
	// Number of sequential scans initiated on this table
	SeqScan nullable.Int64 `json:"seq_scan"`
	// Number of live rows fetched by sequential scans
	SeqTupRead nullable.Int64 `json:"seq_tup_read"`
	// Number of index scans initiated on this table
	IdxScan nullable.Int64 `json:"idx_scan"`
	// Number of live rows fetched by index scans
	IdxTupFetch nullable.Int64 `json:"idx_tup_fetch"`
	// Number of rows inserted
	NTupIns nullable.Int64 `json:"n_tup_ins"`
	// Number of rows updated (includes HOT updated rows)
	NTupUpd nullable.Int64 `json:"n_tup_upd"`
	// Number of rows deleted
	NTupDel nullable.Int64 `json:"n_tup_del"`
	// Number of rows HOT updated (i.e., with no separate index update required)
	NTupHotUpd nullable.Int64 `json:"n_tup_hot_upd"`
	// Estimated number of live rows
	NLiveTup nullable.Int64 `json:"n_live_tup"`
	// Estimated number of dead rows
	NDeadTup nullable.Int64 `json:"n_dead_tup"`
	// Estimated number of rows modified since this table was last analyzed
	NModSinceAnalyze nullable.Int64 `json:"n_mod_since_analyze"`
	// Last time at which this table was manually vacuumed (not counting VACUUM FULL)
	LastVacuum nullable.Time `json:"last_vacuum"`
	// Last time at which this table was vacuumed by the autovacuum daemon
	LastAutovacuum nullable.Time `json:"last_autovacuum"`
	// Last time at which this table was manually analyzed
	LastAnalyze nullable.Time `json:"last_analyze"`
	// Last time at which this table was analyzed by the autovacuum daemon
	LastAutoanalyze nullable.Time `json:"last_autoanalyze"`
	// Number of times this table has been manually vacuumed (not counting VACUUM FULL)
	VacuumCount nullable.Int64 `json:"vacuum_count"`
	// Number of times this table has been vacuumed by the autovacuum daemon
	AutovacuumCount nullable.Int64 `json:"autovacuum_count"`
	// Number of times this table has been manually analyzed
	AnalyzeCount nullable.Int64 `json:"analyze_count"`
	// Number of times this table has been analyzed by the autovacuum daemon
	AutoanalyzeCount nullable.Int64 `json:"autoanalyze_count"`
}

PgStatTablesRow represents schema of pg_stat_*_tables views

type PgStatUserFunctionsView

type PgStatUserFunctionsView []PgStatFunctionsRow

PgStatUserFunctionsView represents content of pg_stat_user_functions view

func PgStatUserFunctions added in v1.0.0

func PgStatUserFunctions() (PgStatUserFunctionsView, error)

PgStatUserFunctions returns a slice containing statistics about executions of each tracked function in the current database.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-USER-FUNCTIONS-VIEW

type PgStatUserIndexesView

type PgStatUserIndexesView []PgStatIndexesRow

PgStatUserIndexesView represents content of pg_stat_user_indexes view

func PgStatUserIndexes added in v1.0.0

func PgStatUserIndexes() (PgStatUserIndexesView, error)

PgStatUserIndexes returns a slice containing statistics about accesses to each user-defined index in the current database.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ALL-INDEXES-VIEW

type PgStatUserTablesView

type PgStatUserTablesView []PgStatTablesRow

PgStatUserTablesView represents content of pg_stat_user_tables view

func PgStatUserTables added in v1.0.0

func PgStatUserTables() (PgStatUserTablesView, error)

PgStatUserTables returns a slice containing statistics about accesses to each user-defined table in the current database (including TOAST tables).

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ALL-TABLES-VIEW

type PgStatWalReceiverView added in v0.2.0

type PgStatWalReceiverView struct {
	// Process ID of the WAL receiver process
	Pid int64 `json:"pid"`
	// Activity status of the WAL receiver process
	Status string `json:"status"`
	// First write-ahead log location used when WAL receiver is started
	ReceiveStartLsn nullable.Int64 `json:"receive_start_lsn"`
	// First timeline number used when WAL receiver is started
	ReceiveStartTli nullable.Int64 `json:"receive_start_tli"`
	// Last write-ahead log location already received and flushed to disk,
	// the initial value of this field being the first log location used when WAL receiver is started
	ReceivedLsn nullable.Int64 `json:"received_lsn"`
	// Timeline number of last write-ahead log location received and flushed to disk,
	// the initial value of this field being the timeline number of the first log location used when WAL receiver is started
	ReceivedTli nullable.Int64 `json:"received_tli"`
	// Send time of last message received from origin WAL sender
	LastMsgSendTime nullable.Time `json:"last_msg_send_time"`
	// Receipt time of last message received from origin WAL sender
	LastMsgReceiptTime nullable.Time `json:"last_msg_receipt_time"`
	// Last write-ahead log location reported to origin WAL sender
	LatestEndLsn nullable.Int64 `json:"latest_end_lsn"`
	// Time of last write-ahead log location reported to origin WAL sender
	LatestEndTime nullable.Time `json:"latest_end_time"`
	// Replication slot name used by this WAL receiver
	SlotName nullable.String `json:"slot_name"`
	// Host of the PostgreSQL instance this WAL receiver is connected to.
	// This can be a host name, an IP address, or a directory path if the connection is via Unix socket.
	// (The path case can be distinguished because it will always be an absolute path, beginning with /.)
	// Supported since PostgreSQL 11
	SenderHost nullable.String `json:"sender_host"`
	// Port number of the PostgreSQL instance this WAL receiver is connected to.
	// Supported since PostgreSQL 11
	SenderPort nullable.Int64 `json:"sender_port"`
	// Connection string used by this WAL receiver, with security-sensitive fields obfuscated.
	Conninfo nullable.String `json:"conninfo"`
}

PgStatWalReceiverView represents content of pg_stat_wal_receiver view

func PgStatWalReceiver added in v1.0.0

func PgStatWalReceiver() (PgStatWalReceiverView, error)

PgStatWalReceiver returns a single struct, containing statistics about the WAL receiver from that receiver's connected server.

Supported since PostgreSQL 9.6.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-WAL-RECEIVER-VIEW

type PgStatXactAllTablesView

type PgStatXactAllTablesView []PgStatXactTablesRow

PgStatXactAllTablesView represents content of pg_stat_xact_all_tables view

func PgStatXactAllTables added in v1.0.0

func PgStatXactAllTables() (PgStatXactAllTablesView, error)

PgStatXactAllTables returns a slice containing statistics about accesses to each table in the current database (including TOAST tables), but counts only actions taken so far within the current transaction (which are not yet included in pg_stat_all_tables and related views).

type PgStatXactSystemTablesView

type PgStatXactSystemTablesView []PgStatXactTablesRow

PgStatXactSystemTablesView represents content of pg_stat_xact_system_tables view

func PgStatXactSystemTables added in v1.0.0

func PgStatXactSystemTables() (PgStatXactSystemTablesView, error)

PgStatXactSystemTables returns a slice containing statistics about accesses to each system table in the current database (including TOAST tables), but counts only actions taken so far within the current transaction (which are not yet included in pg_stat_all_tables and related views).

type PgStatXactTablesRow

type PgStatXactTablesRow struct {
	// OID of a table
	Relid int64 `json:"relid"`
	// Name of the schema that this table is in
	Schemaname string `json:"schemaname"`
	// Name of this table
	Relname string `json:"relname"`
	// Number of sequential scans initiated on this table
	SeqScan nullable.Int64 `json:"seq_scan"`
	// Number of live rows fetched by sequential scans
	SeqTupRead nullable.Int64 `json:"seq_tup_read"`
	// Number of index scans initiated on this table
	IdxScan nullable.Int64 `json:"idx_scan"`
	// Number of live rows fetched by index scans
	IdxTupFetch nullable.Int64 `json:"idx_tup_fetch"`
	// Number of rows inserted
	NTupIns nullable.Int64 `json:"n_tup_ins"`
	// Number of rows updated (includes HOT updated rows)
	NTupUpd nullable.Int64 `json:"n_tup_upd"`
	// Number of rows deleted
	NTupDel nullable.Int64 `json:"n_tup_del"`
	// Number of rows HOT updated (i.e., with no separate index update required)
	NTupHotUpd nullable.Int64 `json:"n_tup_hot_upd"`
}

PgStatXactTablesRow represents schema of pg_stat_xact_*_tables views

type PgStatXactUserFunctionsView

type PgStatXactUserFunctionsView []PgStatFunctionsRow

PgStatXactUserFunctionsView represents content of pg_stat_xact_user_functions view

func PgStatXactUserFunctions added in v1.0.0

func PgStatXactUserFunctions() (PgStatXactUserFunctionsView, error)

PgStatXactUserFunctions returns a slice containing statistics about executions of each tracked function in the current database, but counts only calls during the current transaction (which are not yet included in pg_stat_user_functions).

type PgStatXactUserTablesView

type PgStatXactUserTablesView []PgStatXactTablesRow

PgStatXactUserTablesView represents content of pg_stat_xact_user_tables view

func PgStatXactUserTables added in v1.0.0

func PgStatXactUserTables() (PgStatXactUserTablesView, error)

PgStatXactUserTables returns a slice containing statistics about accesses to each user-defined table in the current database (including TOAST tables), but counts only actions taken so far within the current transaction (which are not yet included in pg_stat_all_tables and related views).

type PgStats

type PgStats struct {
	// contains filtered or unexported fields
}

PgStats holds a single connection to the database and provides a convenient access to all postgres monitoring statistics.

func Connect

func Connect(dbname string, user string, password string, options ...Option) (*PgStats, error)

Connect opens a connection using provided parameters and returns a pointer to newly created PgStats struct.

func (*PgStats) Close

func (s *PgStats) Close() error

Close closes the connection to database.

func (*PgStats) PgStatActivity

func (s *PgStats) PgStatActivity() (PgStatActivityView, error)

PgStatActivity returns a slice, containing information related to the current activity of a process, such as state and current query, for each server process.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW

func (*PgStats) PgStatAllIndexes

func (s *PgStats) PgStatAllIndexes() (PgStatAllIndexesView, error)

PgStatAllIndexes returns a slice containing statistics about accesses to each index in the current database.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ALL-INDEXES-VIEW

func (*PgStats) PgStatAllTables

func (s *PgStats) PgStatAllTables() (PgStatAllTablesView, error)

PgStatAllTables returns a slice containing statistics about accesses to each table in the current database (including TOAST tables).

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ALL-TABLES-VIEW

func (*PgStats) PgStatArchiver

func (s *PgStats) PgStatArchiver() (PgStatArchiverView, error)

PgStatArchiver returns a single struct, containing global data for the cluster, showing statistics about the WAL archiver process's activity.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ARCHIVER-VIEW

func (*PgStats) PgStatBgWriter

func (s *PgStats) PgStatBgWriter() (PgStatBgWriterView, error)

PgStatBgWriter returns a single struct, containing global data for the cluster, showing statistics about the background writer process's activity.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW

func (*PgStats) PgStatDatabase

func (s *PgStats) PgStatDatabase() (PgStatDatabaseView, error)

PgStatDatabase returns a slice containing database-wide statistics for each database in the cluster.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW

func (*PgStats) PgStatDatabaseConflicts

func (s *PgStats) PgStatDatabaseConflicts() (PgStatDatabaseConflictsView, error)

PgStatDatabaseConflicts returns a slice containing database-wide statistics for each database in the cluster about query cancels occurring due to conflicts with recovery on standby servers. This will only contain information on standby servers, since conflicts do not occur on master servers.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-CONFLICTS-VIEW

func (*PgStats) PgStatIoAllIndexes

func (s *PgStats) PgStatIoAllIndexes() (PgStatIoAllIndexesView, error)

PgStatIoAllIndexes returns a slice containing statistics about I/O on each index in the current database.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STATIO-ALL-INDEXES-VIEW

func (*PgStats) PgStatIoAllSequences

func (s *PgStats) PgStatIoAllSequences() (PgStatIoAllSequencesView, error)

PgStatIoAllSequences returns a slice containing statistics about I/O on each sequence in the current database.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STATIO-ALL-SEQUENCES-VIEW

func (*PgStats) PgStatIoAllTables

func (s *PgStats) PgStatIoAllTables() (PgStatIoAllTablesView, error)

PgStatIoAllTables returns a slice containing statistics about I/O on each table in the current database (including TOAST tables).

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STATIO-ALL-TABLES-VIEW

func (*PgStats) PgStatIoSystemIndexes

func (s *PgStats) PgStatIoSystemIndexes() (PgStatIoSystemIndexesView, error)

PgStatIoSystemIndexes returns a slice containing statistics about I/O on each system index in the current database.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STATIO-ALL-INDEXES-VIEW

func (*PgStats) PgStatIoSystemSequences

func (s *PgStats) PgStatIoSystemSequences() (PgStatIoSystemSequencesView, error)

PgStatIoSystemSequences returns a slice containing statistics about I/O on each system sequence in the current database. (As of PostgreSQL 11, no system sequences are defined, so this view is always empty.)

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STATIO-ALL-SEQUENCES-VIEW

func (*PgStats) PgStatIoSystemTables

func (s *PgStats) PgStatIoSystemTables() (PgStatIoSystemTablesView, error)

PgStatIoSystemTables returns a slice containing statistics about I/O on each system table in the current database (including TOAST tables).

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STATIO-ALL-TABLES-VIEW

func (*PgStats) PgStatIoUserIndexes

func (s *PgStats) PgStatIoUserIndexes() (PgStatIoUserIndexesView, error)

PgStatIoUserIndexes returns a slice containing statistics about I/O on each user-defined index in the current database.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STATIO-ALL-INDEXES-VIEW

func (*PgStats) PgStatIoUserSequences

func (s *PgStats) PgStatIoUserSequences() (PgStatIoUserSequencesView, error)

PgStatIoUserSequences returns a slice containing statistics about I/O on each user-defined sequence in the current database.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STATIO-ALL-SEQUENCES-VIEW

func (*PgStats) PgStatIoUserTables

func (s *PgStats) PgStatIoUserTables() (PgStatIoUserTablesView, error)

PgStatIoUserTables returns a slice containing statistics about I/O on each user-defined table in the current database (including TOAST tables).

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STATIO-ALL-TABLES-VIEW

func (*PgStats) PgStatProgressVacuum

func (s *PgStats) PgStatProgressVacuum() (PgStatProgressVacuumView, error)

PgStatProgressVacuum returns a slice, containing information related to currently running VACUUM processes, for each backend (including autovacuum worker processes) that is currently vacuuming. Progress reporting is not currently supported for VACUUM FULL and backends running VACUUM FULL will not be listed in this view.

Supported since PostgreSQL 9.6.

For more details, see: https://www.postgresql.org/docs/current/progress-reporting.html#VACUUM-PROGRESS-REPORTING

func (*PgStats) PgStatReplication added in v0.2.0

func (s *PgStats) PgStatReplication() (PgStatReplicationView, error)

PgStatReplication returns a slice, containing statistics about each WAL sender process, showing information about replication to that sender's connected standby server.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-REPLICATION-VIEW

func (*PgStats) PgStatSsl

func (s *PgStats) PgStatSsl() (PgStatSslView, error)

PgStatSsl returns a slice, containing statistics about SSL usage on the connection for each backend or WAL sender process.

Supported since PostgreSQL 9.5.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-SSL

func (*PgStats) PgStatStatements added in v0.2.0

func (s *PgStats) PgStatStatements() (PgStatStatementsView, error)

PgStatStatements returns a slice containing statistics about executions of all SQL statements in the current database.

For more details, see: https://www.postgresql.org/docs/current/pgstatstatements.html

func (*PgStats) PgStatSubscription added in v0.2.0

func (s *PgStats) PgStatSubscription() (PgStatSubscriptionView, error)

PgStatSubscription returns a slice, containing statistics about subscription for main worker (with null PID if the worker is not running), and workers handling the initial data copy of the subscribed tables.

Supported since PostgreSQL 10.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-SUBSCRIPTION

func (*PgStats) PgStatSystemIndexes

func (s *PgStats) PgStatSystemIndexes() (PgStatSystemIndexesView, error)

PgStatSystemIndexes returns a slice containing statistics about accesses to each system index in the current database.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ALL-INDEXES-VIEW

func (*PgStats) PgStatSystemTables

func (s *PgStats) PgStatSystemTables() (PgStatSystemTablesView, error)

PgStatSystemTables returns a slice containing statistics about accesses to each system table in the current database (including TOAST tables).

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ALL-TABLES-VIEW

func (*PgStats) PgStatUserFunctions

func (s *PgStats) PgStatUserFunctions() (PgStatUserFunctionsView, error)

PgStatUserFunctions returns a slice containing statistics about executions of each tracked function in the current database.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-USER-FUNCTIONS-VIEW

func (*PgStats) PgStatUserIndexes

func (s *PgStats) PgStatUserIndexes() (PgStatUserIndexesView, error)

PgStatUserIndexes returns a slice containing statistics about accesses to each user-defined index in the current database.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ALL-INDEXES-VIEW

func (*PgStats) PgStatUserTables

func (s *PgStats) PgStatUserTables() (PgStatUserTablesView, error)

PgStatUserTables returns a slice containing statistics about accesses to each user-defined table in the current database (including TOAST tables).

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ALL-TABLES-VIEW

func (*PgStats) PgStatWalReceiver added in v0.2.0

func (s *PgStats) PgStatWalReceiver() (PgStatWalReceiverView, error)

PgStatWalReceiver returns a single struct, containing statistics about the WAL receiver from that receiver's connected server.

Supported since PostgreSQL 9.6.

For more details, see: https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-WAL-RECEIVER-VIEW

func (*PgStats) PgStatXactAllTables

func (s *PgStats) PgStatXactAllTables() (PgStatXactAllTablesView, error)

PgStatXactAllTables returns a slice containing statistics about accesses to each table in the current database (including TOAST tables), but counts only actions taken so far within the current transaction (which are not yet included in pg_stat_all_tables and related views).

func (*PgStats) PgStatXactSystemTables

func (s *PgStats) PgStatXactSystemTables() (PgStatXactSystemTablesView, error)

PgStatXactSystemTables returns a slice containing statistics about accesses to each system table in the current database (including TOAST tables), but counts only actions taken so far within the current transaction (which are not yet included in pg_stat_all_tables and related views).

func (*PgStats) PgStatXactUserFunctions

func (s *PgStats) PgStatXactUserFunctions() (PgStatXactUserFunctionsView, error)

PgStatXactUserFunctions returns a slice containing statistics about executions of each tracked function in the current database, but counts only calls during the current transaction (which are not yet included in pg_stat_user_functions).

func (*PgStats) PgStatXactUserTables

func (s *PgStats) PgStatXactUserTables() (PgStatXactUserTablesView, error)

PgStatXactUserTables returns a slice containing statistics about accesses to each user-defined table in the current database (including TOAST tables), but counts only actions taken so far within the current transaction (which are not yet included in pg_stat_all_tables and related views).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL