f005

package
v0.0.0-...-b15899e Latest Latest
Warning

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

Go to latest
Published: May 7, 2021 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const CRITICAL_BLOAT_RATIO float32 = 90.0
View Source
const CRITICAL_TOTAL_BLOAT_RATIO float32 = 20.0
View Source
const F005_BLOATED_INDEXES string = "F005_BLOATED_INDEXES"
View Source
const F005_BLOATED_TABLE_INDEXES string = "F005_BLOATED_TABLE_INDEXES"
View Source
const F005_BLOAT_CRITICAL string = "F005_BLOAT_CRITICAL"
View Source
const F005_BLOAT_CRITICAL_INFO string = "F005_BLOAT_CRITICAL_INFO"
View Source
const F005_BLOAT_EXCESS_INFO string = "F005_BLOAT_EXCESS_INFO"
View Source
const F005_BLOAT_INFO string = "F005_BLOAT_INFO"
View Source
const F005_BLOAT_WARNING string = "F005_BLOAT_WARNING"
View Source
const F005_GENERAL_INFO string = "F005_GENERAL_INFO"
View Source
const F005_TOTAL_BLOAT_EXCESS string = "F005_TOTAL_BLOAT_EXCESS"
View Source
const F005_TOTAL_BLOAT_LOW string = "F005_TOTAL_BLOAT_LOW"
View Source
const INDEX_DETAILS string = "    - `%s`: size %s, can be reduced %.2f times, by ~%s (~%.2f%%)\n"
View Source
const MIN_INDEX_SIZE_TO_ANALYZE int64 = 1024 * 1024
View Source
const MSG_BLOAT_CRITICAL_CONCLUSION_1 string = "[P1] The following %d index has significant size (>1 MiB) and bloat estimate > %.2f%%:  \n%s  \n"
View Source
const MSG_BLOAT_CRITICAL_CONCLUSION_N string = "[P1] The following %d indexes have significant size (>1 MiB) and bloat estimate > %.2f%%:  \n%s  \n"
View Source
const MSG_BLOAT_CRITICAL_RECOMMENDATION string = "[P1] Reduce and prevent a high level of index bloat:\n" +
	"    - to prevent a high level of bloat in the future, tune autovacuum: consider more aggressive autovacuum settings (see F001);\n" +
	"    - eliminate or reduce the current index bloat using one of the approaches listed below.\n"
View Source
const MSG_BLOAT_GENERAL_RECOMMENDATION_1 string = "If you want to get exact bloat numbers, clone the database, get index sizes, then apply " +
	"database-wide `VACUUM FULL` (it eliminates all the bloat), and get new table sizes. Then compare old and new numbers.\n"
View Source
const MSG_BLOAT_GENERAL_RECOMMENDATION_2 string = "To reduce the index bloat, consider one of the following approaches:\n" +
	"    - [`VACUUM FULL`](https://www.postgresql.org/docs/current/sql-vacuum.html) (:warning:  requires downtime / maintenance window),\n" +
	"    - [`REINDEX`](https://www.postgresql.org/docs/current/sql-reindex.html) (`REINDEX INDEX`, `REINDEX TABLE`; :warning:  requires downtime / maintenance window),\n" +
	"    - recreating indexes online using `CREATE INDEX CONCURRENTLY`, `DROP INDEX CONCURRENTLY` and renaming (not trivial for indexes supporting PK, FK) // `REINDEX CONCURRENTLY` is available in Postgres 12+,\n" +
	"    - one of the tools reducing the bloat online, without interrupting the operations:  \n" +
	"        - [pg_repack](https://github.com/reorg/pg_repack),\n" +
	"        - [pg_squeeze](https://github.com/reorg/pg_repack),\n" +
	"        - [pgcompacttable](https://github.com/dataegret/pgcompacttable).\n"
View Source
const MSG_BLOAT_PX_RECOMMENDATION string = "Read more on this topic:\n" +
	"    - [Index maintenance](https://wiki.postgresql.org/wiki/Index_Maintenance) (PostgreSQL wiki)\n" +
	"    - [Btree bloat query](http://blog.ioguix.net/postgresql/2014/11/03/Btree-bloat-query-part-4.html) (2014, ioguix)\n" +
	"    - [PostgreSQL Index bloat under a microscope](http://pgeoghegan.blogspot.com/2017/07/postgresql-index-bloat-microscope.html) (2017, Peter Geoghegan)\n" +
	"    - [PostgreSQL Bloat: origins, monitoring and managing](https://www.compose.com/articles/postgresql-bloat-origins-monitoring-and-managing/) (2016, Compose)  \n" +
	"    - [Dealing with significant Postgres database bloat — what are your options?](Dealing with significant Postgres database bloat — what are your options?) (2018, Compass)\n" +
	"    - [Postgres database bloat analysis](https://about.gitlab.com/handbook/engineering/infrastructure/blueprint/201901-postgres-bloat/) (2019, GitLab)\n"
View Source
const MSG_BLOAT_WARNING_CONCLUSION_1 string = "[P2] There is %d index with size > 1 MiB and index bloat estimate >= %.2f%% and < %.2f%%:  \n%s  \n"
View Source
const MSG_BLOAT_WARNING_CONCLUSION_N string = "[P2] There are %d indexes with size > 1 MiB and index bloat estimate >= %.2f%% and < %.2f%%:  \n%s  \n"
View Source
const MSG_BLOAT_WARNING_RECOMMENDATION string = "[P2] Consider the following:\n" +
	"    - to prevent a high level of bloat in the future, tune autovacuum: consider more aggressive autovacuum settings (see F001);\n" +
	"    - eliminate or reduce the current index bloat using one of the approaches listed below.\n"
View Source
const MSG_BLOAT_WARNING_RECOMMENDATION_INDEXES string = "" /* 184-byte string literal not displayed */
View Source
const MSG_BLOAT_WARNING_RECOMMENDATION_TABLE_INDEXES string = "" /* 258-byte string literal not displayed */
View Source
const MSG_NO_RECOMMENDATIONS string = "All good 👍"
View Source
const MSG_TOTAL_BLOAT_EXCESS_CONCLUSION string = "[P1] Total index (btree only) bloat estimation is ~%s, it is %.2f%% of the overall size of all indexes and %.2f%% of the DB size. " +
	"Removing the index bloat will reduce the total DB size down to ~%s. Free disk space will be increased by ~%s. " +
	"Total size of indexes is %.2f times bigger than it could be. " +
	"Notice that this is only an estimation, sometimes it may be significantly off.\n"
View Source
const MSG_TOTAL_BLOAT_LOW_CONCLUSION string = "" /* 129-byte string literal not displayed */
View Source
const WARNING_BLOAT_RATIO float32 = 40.0

Variables

This section is empty.

Functions

func F005PreprocessReportData

func F005PreprocessReportData(data map[string]interface{})

func F005Process

func F005Process(report F005Report, bloatedTables []string) checkup.ReportResult

Generate conclusions and recommendatons

Types

type F005IndexBloat

type F005IndexBloat struct {
	Num                int     `json:"num"`
	IsNa               string  `json:"is_na"`
	IndexName          string  `json:"index_name"`
	SchemaName         string  `json:"schema_name"`
	TableName          string  `json:"table_name"`
	IndexTableName     string  `json:"index_table_name"`
	RealSizeBytes      int64   `json:"real_size_bytes"`
	Size               string  `json:"size"`
	ExtraRatioPercent  float32 `json:"extra_ratio_percent"`
	ExtraSizeBytes     int64   `json:"extra_size_bytes"`
	BloatSizeBytes     int64   `json:"bloat_size_bytes"`
	BloatRatioPercent  float32 `json:"bloat_ratio_percent"`
	BloatRatioFactor   float32 `json:"bloat_ratio_factor"`
	LiveDataSizeBytes  int64   `json:"live_data_size_bytes"`
	LastVaccuum        string  `json:"last_vaccuum"`
	Fillfactor         float32 `json:"fillfactor"`
	OverriddenSettings bool    `json:"overridden_settings"`
	TableSizeBytes     int64   `json:"table_size_bytes"`
}

type F005IndexBloatTotal

type F005IndexBloatTotal struct {
	Count                int     `json:"count"`
	ExtraSizeBytesSum    int64   `json:"extra_size_bytes_sum"`
	RealSizeBytesSum     int64   `json:"real_size_bytes_sum"`
	BloatSizeBytesSum    int64   `json:"bloat_size_bytes_sum"`
	BloatRatioFactorAvg  float32 `json:"bloat_ratio_factor_avg"`
	BloatRatioPercentAvg float32 `json:"bloat_ratio_percent_avg"`
	TableSizeBytesSum    float32 `json:"table_size_bytes_sum"`
	LiveDataSizeBytesSum int64   `json:"live_data_size_bytes_sum"`
}

Current database tables list

type F005Report

type F005Report struct {
	Project       string                  `json:"project"`
	Name          string                  `json:"name"`
	CheckId       string                  `json:"checkId"`
	Timestamptz   string                  `json:"timestamptz"`
	Database      string                  `json:"database"`
	Dependencies  map[string]interface{}  `json:"dependencies"`
	LastNodesJson checkup.ReportLastNodes `json:"last_nodes_json"`
	Results       F005ReportHostsResults  `json:"results"`
}

type F005ReportHostResult

type F005ReportHostResult struct {
	Data      F005ReportHostResultData `json:"data"`
	NodesJson checkup.ReportLastNodes  `json:"nodes.json"`
}

type F005ReportHostResultData

type F005ReportHostResultData struct {
	IndexBloat              map[string]F005IndexBloat `json:"Index_bloat"`
	IndexBloatTotal         F005IndexBloatTotal       `json:"Index_bloat_total"`
	OverriddenSettingsCount int                       `json:"overridden_settings_count"`
	DatabaseSizeBytes       int64                     `json:"database_size_bytes"`
}

type F005ReportHostsResults

type F005ReportHostsResults map[string]F005ReportHostResult

Jump to

Keyboard shortcuts

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