postgres

package
v0.51.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2023 License: BSD-2-Clause, BSD-3-Clause, PostgreSQL Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const HelperReadLogFile = `` /* 220-byte string literal not displayed */
View Source
const LogFileSql = "SELECT name FROM pg_catalog.pg_ls_logdir() WHERE modification > pg_catalog.now() - '2 minute'::interval"
View Source
const QueryMarkerSQL string = "/* pganalyze-collector */ "
View Source
const SuperUserReadLogFileSql = `` /* 330-byte string literal not displayed */

Read at most the trailing 10 megabytes of each file

Variables

This section is empty.

Functions

func CollectAllSchemas

func CollectAllSchemas(ctx context.Context, server *state.Server, collectionOpts state.CollectionOpts, logger *util.Logger, ps state.PersistedState, ts state.TransientState, systemType string) (state.PersistedState, state.TransientState, error)

func CurrentDatabaseName

func CurrentDatabaseName(ctx context.Context, db *sql.DB) (result string, err error)

CurrentDatabaseName - Get name of the database we're currently connected to

func CurrentDatabaseOid

func CurrentDatabaseOid(ctx context.Context, db *sql.DB) (result state.Oid, err error)

CurrentDatabaseOid - Find OID of the database we're currently connected to

func EstablishConnection

func EstablishConnection(ctx context.Context, server *state.Server, logger *util.Logger, globalCollectionOpts state.CollectionOpts, databaseName string) (connection *sql.DB, err error)

func GetBackendCounts

func GetBackendCounts(ctx context.Context, logger *util.Logger, db *sql.DB, postgresVersion state.PostgresVersion, systemType string) ([]state.PostgresBackendCount, error)

func GetBackends

func GetBackends(ctx context.Context, logger *util.Logger, db *sql.DB, postgresVersion state.PostgresVersion, systemType string, collectPostgresLocks bool) ([]state.PostgresBackend, error)

func GetBloatStats

func GetBloatStats(ctx context.Context, logger *util.Logger, db *sql.DB, systemType, ignoreRegexp string) (report state.PostgresBloatStats, err error)

func GetBuffercache

func GetBuffercache(ctx context.Context, logger *util.Logger, db *sql.DB, systemType, ignoreRegexp string) (report state.PostgresBuffercache, err error)

func GetColumnStats added in v0.41.0

func GetColumnStats(ctx context.Context, logger *util.Logger, db *sql.DB, globalCollectionOpts state.CollectionOpts, systemType string, dbName string) (columnStats state.PostgresColumnStatsMap, err error)

func GetDatabases

func GetDatabases(ctx context.Context, logger *util.Logger, db *sql.DB, postgresVersion state.PostgresVersion) ([]state.PostgresDatabase, state.PostgresDatabaseStatsMap, error)

func GetExtensions added in v0.45.0

func GetExtensions(ctx context.Context, db *sql.DB, currentDatabaseOid state.Oid) ([]state.PostgresExtension, error)

func GetFunctionStats

func GetFunctionStats(ctx context.Context, db *sql.DB, postgresVersion state.PostgresVersion, ignoreRegexp string) (functionStats state.PostgresFunctionStatsMap, err error)

func GetFunctions

func GetFunctions(ctx context.Context, db *sql.DB, postgresVersion state.PostgresVersion, currentDatabaseOid state.Oid, ignoreRegexp string) ([]state.PostgresFunction, error)

func GetIndexBloat

func GetIndexBloat(ctx context.Context, logger *util.Logger, db *sql.DB, columnStatsSourceTable, ignoreRegexp string) (indexBloat []state.PostgresIndexBloat, err error)

func GetIndexStats

func GetIndexStats(ctx context.Context, db *sql.DB, postgresVersion state.PostgresVersion, server *state.Server) (indexStats state.PostgresIndexStatsMap, err error)

func GetIsAwsAurora

func GetIsAwsAurora(ctx context.Context, db *sql.DB) (bool, error)

func GetIsReplica

func GetIsReplica(ctx context.Context, logger *util.Logger, db *sql.DB) (bool, error)

func GetPostgresSetting

func GetPostgresSetting(ctx context.Context, settingName string, server *state.Server, globalCollectionOpts state.CollectionOpts, prefixedLogger *util.Logger) (string, error)

func GetPostgresVersion

func GetPostgresVersion(ctx context.Context, logger *util.Logger, db *sql.DB) (version state.PostgresVersion, err error)

GetPostgresVersion - Reads the version of the connected PostgreSQL server

func GetRelationBloat

func GetRelationBloat(ctx context.Context, logger *util.Logger, db *sql.DB, columnStatsSourceTable string, ignoreRegexp string) (relBloat []state.PostgresRelationBloat, err error)

func GetRelationStats

func GetRelationStats(ctx context.Context, db *sql.DB, postgresVersion state.PostgresVersion, server *state.Server) (relStats state.PostgresRelationStatsMap, err error)

func GetRelations

func GetRelations(ctx context.Context, db *sql.DB, postgresVersion state.PostgresVersion, currentDatabaseOid state.Oid, ignoreRegexp string) ([]state.PostgresRelation, error)

func GetReplication

func GetReplication(ctx context.Context, logger *util.Logger, db *sql.DB, postgresVersion state.PostgresVersion, systemType string) (state.PostgresReplication, error)

func GetRoles

func GetRoles(ctx context.Context, logger *util.Logger, db *sql.DB, postgresVersion state.PostgresVersion) ([]state.PostgresRole, error)

func GetSequenceReport

func GetSequenceReport(ctx context.Context, logger *util.Logger, db *sql.DB) (report state.PostgresSequenceReport, err error)

func GetServerStats added in v0.47.0

func GetServerStats(ctx context.Context, logger *util.Logger, db *sql.DB, postgresVersion state.PostgresVersion, systemType string) (state.PostgresServerStats, error)

func GetSettings

func GetSettings(ctx context.Context, db *sql.DB) ([]state.PostgresSetting, error)

func GetStatements

func GetStatements(ctx context.Context, server *state.Server, logger *util.Logger, db *sql.DB, globalCollectionOpts state.CollectionOpts, postgresVersion state.PostgresVersion, showtext bool, systemType string) (state.PostgresStatementMap, state.PostgresStatementTextMap, state.PostgresStatementStatsMap, error)

func GetTypes added in v0.41.0

func GetTypes(ctx context.Context, db *sql.DB, postgresVersion state.PostgresVersion, currentDatabaseOid state.Oid) ([]state.PostgresType, error)

func GetVacuumProgress

func GetVacuumProgress(ctx context.Context, logger *util.Logger, db *sql.DB, postgresVersion state.PostgresVersion, ignoreRegexp string) ([]state.PostgresVacuumProgress, error)

func GetVacuumStats

func GetVacuumStats(ctx context.Context, logger *util.Logger, db *sql.DB, ignoreRegexp string) (report state.PostgresVacuumStats, err error)

func LogPgReadFile added in v0.45.0

func LogPgReadFile(ctx context.Context, server *state.Server, globalCollectionOpts state.CollectionOpts, logger *util.Logger) (state.PersistedLogState, []state.LogFile, []state.PostgresQuerySample, error)

LogPgReadFile - Gets log files using the pg_read_file function

func ResetStatements

func ResetStatements(ctx context.Context, logger *util.Logger, db *sql.DB, systemType string) error

func RunExplain

func RunExplain(ctx context.Context, server *state.Server, inputs []state.PostgresQuerySample, collectionOpts state.CollectionOpts, logger *util.Logger) (outputs []state.PostgresQuerySample)

func SetDefaultStatementTimeout

func SetDefaultStatementTimeout(ctx context.Context, connection *sql.DB, logger *util.Logger, server *state.Server) error

func SetQueryTextStatementTimeout

func SetQueryTextStatementTimeout(ctx context.Context, connection *sql.DB, logger *util.Logger, server *state.Server) error

func SetStatementTimeout

func SetStatementTimeout(ctx context.Context, connection *sql.DB, statementTimeoutMs int32) error

func StatsHelperExists added in v0.43.0

func StatsHelperExists(ctx context.Context, db *sql.DB, statsHelper string) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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