Skip to content

Commit ed3423b

Browse files
committed
fix: skip standbys in stale stats detector
1 parent 53b5f74 commit ed3423b

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

internal/schema/types.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ type StaleStatsEntry struct {
243243
LastAnalyzedDaysAgo *int64 `json:"last_analyzed_days_ago,omitempty"`
244244
}
245245

246-
// Walks MergedActivity per-node looking for tables without a recent (auto)analyze
246+
// Skip standbys: pg_statistic replicates via WAL but pg_stat_user_tables timestamps are per-node and autoanalyze never runs there.
247247
func DetectStaleStats(a *AnnotatedSchema, staleDays int64) []StaleStatsEntry {
248248
if a == nil || a.Merged == nil {
249249
return nil
@@ -253,6 +253,9 @@ func DetectStaleStats(a *AnnotatedSchema, staleDays int64) []StaleStatsEntry {
253253
var entries []StaleStatsEntry
254254

255255
for _, n := range a.Merged.Nodes {
256+
if n.Node.IsStandby {
257+
continue
258+
}
256259
for _, ts := range n.Tables {
257260
var lastAnalyzed *time.Time
258261
if ts.Activity.LastAnalyze != nil {

0 commit comments

Comments
 (0)