Skip to content

Commit

Permalink
Add option to avoid collecting distributed index stats for Citus
Browse files Browse the repository at this point in the history
In some situations, the problems that DISABLE_CITUS_SCHEMA_STATS is
intended to solve are actually only with indexes, not with other
schema stats. By adding an index-specific setting, we can support more
functionality for affected users.
  • Loading branch information
msakrejda committed Jul 9, 2024
1 parent b271dc9 commit b9f4ed9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ type ServerConfig struct {

AlwaysCollectSystemData bool `ini:"always_collect_system_data"`
DisableCitusSchemaStats bool `ini:"disable_citus_schema_stats"`
DisableCitusIndexStats bool `ini:"disable_citus_index_stats"`

// Configures the location where logfiles are - this can either be a directory,
// or a file - needs to readable by the regular pganalyze user
Expand Down
3 changes: 3 additions & 0 deletions config/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ func getDefaultConfig() *ServerConfig {
if disableCitusSchemaStats := os.Getenv("DISABLE_CITUS_SCHEMA_STATS"); disableCitusSchemaStats != "" {
config.DisableCitusSchemaStats = parseConfigBool(disableCitusSchemaStats)
}
if disableCitusIndexStats := os.Getenv("DISABLE_CITUS_INDEX_STATS"); disableCitusIndexStats != "" {
config.DisableCitusIndexStats = parseConfigBool(disableCitusIndexStats)
}
if logPgReadFile := os.Getenv("LOG_PG_READ_FILE"); logPgReadFile != "" {
config.LogPgReadFile = parseConfigBool(logPgReadFile)
}
Expand Down
2 changes: 1 addition & 1 deletion input/postgres/relation_stats_aux.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ GROUP BY
`

func handleIndexStatsAux(ctx context.Context, db *sql.DB, idxStats state.PostgresIndexStatsMap, postgresVersion state.PostgresVersion, server *state.Server) (state.PostgresIndexStatsMap, error) {
if postgresVersion.IsCitus && !server.Config.DisableCitusSchemaStats {
if postgresVersion.IsCitus && !server.Config.DisableCitusSchemaStats && !server.Config.DisableCitusIndexStats {
stmt, err := db.PrepareContext(ctx, QueryMarkerSQL+citusIndexSizeSQL)
if err != nil {
return idxStats, fmt.Errorf("IndexStatsExt/Prepare: %s", err)
Expand Down

0 comments on commit b9f4ed9

Please sign in to comment.