Documentation
¶
Overview ¶
Package pgdoctor implements health checks for common misconfiguration and issues of PostgreSQL databases.
Index ¶
- Constants
- func AllChecks() []check.Package
- func AllFilters() []string
- func Filter(checks []check.Package, only, ignored []string) []check.Package
- func Run(ctx context.Context, conn db.DBTX, opts Options)
- func ValidateFilters(checks []check.Package, filters []string) (valid, invalid []string)
- type Options
- type ReportHandler
Constants ¶
const DefaultStatementTimeoutMs = 2000
DefaultStatementTimeoutMs is the PostgreSQL statement_timeout in milliseconds. Callers should SET this on the connection before calling Run().
Variables ¶
This section is empty.
Functions ¶
func AllChecks ¶
AllChecks returns all available check packages. Consumers call .Metadata() for check information or .New(conn, cfg) to instantiate checkers.
func AllFilters ¶
func AllFilters() []string
AllFilters returns all valid filter values (check IDs and categories).
func Filter ¶ added in v0.2.0
Filter returns checks matching the only/ignored filters. If only is non-empty, only checks matching those check IDs or categories are included. Checks matching ignored check IDs or categories are excluded.
func Run ¶
Run executes checks sequentially against the given connection.
Important: callers should SET statement_timeout on the connection before calling Run() to prevent slow queries from blocking the database. See DefaultStatementTimeoutMs.
func ValidateFilters ¶
ValidateFilters normalizes filter strings and validates them against available checks. Returns valid filters (normalized to check IDs and categories) and invalid filters.
Normalization:
- "check-id" -> "check-id" (exact match)
- "check-id/subcheck-id" -> "check-id" (extracts check ID from subcheck)
- "category" -> "category" (exact match)
Invalid filters are those that don't match any check ID or category.
Types ¶
type Options ¶ added in v0.2.0
type Options struct {
Checks []check.Package
Config check.Config
OnReport ReportHandler
}
Options configures a pgdoctor run.
type ReportHandler ¶ added in v0.2.0
ReportHandler is called once per check after it completes.
func Collect ¶ added in v0.2.0
func Collect(reports *[]*check.Report) ReportHandler
Collect returns a ReportHandler that appends each report to the given slice.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package check defines the core types and interfaces for pgdoctor health checks.
|
Package check defines the core types and interfaces for pgdoctor health checks. |
|
checks
|
|
|
cacheefficiency
Package cacheefficiency implements checks for database buffer cache hit ratio.
|
Package cacheefficiency implements checks for database buffer cache hit ratio. |
|
connectionefficiency
Package connectionefficiency implements checks for PostgreSQL connection pool efficiency.
|
Package connectionefficiency implements checks for PostgreSQL connection pool efficiency. |
|
connectionhealth
Package connectionhealth implements checks for PostgreSQL connection pool health.
|
Package connectionhealth implements checks for PostgreSQL connection pool health. |
|
duplicateindexes
Package duplicateindexes implements checks for identifying duplicate and redundant indexes.
|
Package duplicateindexes implements checks for identifying duplicate and redundant indexes. |
|
freezeage
Package freezeage implements checks for PostgreSQL transaction ID wraparound risk.
|
Package freezeage implements checks for PostgreSQL transaction ID wraparound risk. |
|
indexbloat
Package indexbloat implements checks for PostgreSQL B-tree index bloat estimation.
|
Package indexbloat implements checks for PostgreSQL B-tree index bloat estimation. |
|
indexusage
Package indexusage implements checks for identifying unused and inefficient indexes.
|
Package indexusage implements checks for identifying unused and inefficient indexes. |
|
invalidindexes
Package invalidindexes implements a check for identifying PostgreSQL indexes in an invalid state.
|
Package invalidindexes implements a check for identifying PostgreSQL indexes in an invalid state. |
|
partitioning
Package partitioning implements checks for table partitioning compliance.
|
Package partitioning implements checks for table partitioning compliance. |
|
partitionusage
Package partitionusage implements checks for partition key usage in queries.
|
Package partitionusage implements checks for partition key usage in queries. |
|
pgversion
Package pgversion implements a check for PostgreSQL version compliance and support status.
|
Package pgversion implements a check for PostgreSQL version compliance and support status. |
|
pktypes
Package pktypes validates primary key types for capacity and growth.
|
Package pktypes validates primary key types for capacity and growth. |
|
replicationlag
Package replicationlag implements checks for replication lag monitoring.
|
Package replicationlag implements checks for replication lag monitoring. |
|
replicationslots
Package replicationslots implements a check for PostgreSQL replication slot health.
|
Package replicationslots implements a check for PostgreSQL replication slot health. |
|
sequencehealth
Package sequencehealth implements checks for PostgreSQL sequence capacity and type safety.
|
Package sequencehealth implements checks for PostgreSQL sequence capacity and type safety. |
|
sessionsettings
Package sessionsettings implements a check for validating role-level timeout and logging configurations.
|
Package sessionsettings implements a check for validating role-level timeout and logging configurations. |
|
statisticsfreshness
Package statisticsfreshness validates that PostgreSQL statistics are mature enough for accurate analysis.
|
Package statisticsfreshness validates that PostgreSQL statistics are mature enough for accurate analysis. |
|
tableactivity
Package tableactivity implements checks for table write activity patterns.
|
Package tableactivity implements checks for table write activity patterns. |
|
tablebloat
Package tablebloat implements checks for PostgreSQL table bloat from dead tuples.
|
Package tablebloat implements checks for PostgreSQL table bloat from dead tuples. |
|
tableseqscans
Package tableseqscans implements checks for identifying tables with excessive sequential scan activity.
|
Package tableseqscans implements checks for identifying tables with excessive sequential scan activity. |
|
tablevacuumhealth
Package tablevacuumhealth implements checks for per-table autovacuum configuration.
|
Package tablevacuumhealth implements checks for per-table autovacuum configuration. |
|
tempusage
Package tempusage implements checks for PostgreSQL temporary file creation.
|
Package tempusage implements checks for PostgreSQL temporary file creation. |
|
toaststorage
Package toaststorage implements checks for PostgreSQL TOAST storage analysis.
|
Package toaststorage implements checks for PostgreSQL TOAST storage analysis. |
|
uuiddefaults
Package uuiddefaults detects UUID columns using random UUIDs (v4) as defaults.
|
Package uuiddefaults detects UUID columns using random UUIDs (v4) as defaults. |
|
uuidtypes
Package uuidtypes validates UUID columns use native uuid type.
|
Package uuidtypes validates UUID columns use native uuid type. |
|
vacuumsettings
Package vacuumsettings implements a check for validating autovacuum, maintenance memory, and vacuum cost settings.
|
Package vacuumsettings implements a check for validating autovacuum, maintenance memory, and vacuum cost settings. |
|
cmd
|
|
|
pgdoctor
command
Package main is the entry point for the pgdoctor CLI.
|
Package main is the entry point for the pgdoctor CLI. |
|
internal
|
|
|
cli
Package cli implements the pgdoctor command-line interface.
|
Package cli implements the pgdoctor command-line interface. |
|
gen
command
Package main generates the checks.go file for pgdoctor CLI by discovering check packages.
|
Package main generates the checks.go file for pgdoctor CLI by discovering check packages. |
|
gendocs
command
Package main generates the docs/ directory for pgdoctor's GitHub Pages landing page.
|
Package main generates the docs/ directory for pgdoctor's GitHub Pages landing page. |