Skip to content

Commit

Permalink
chore: adjust messages
Browse files Browse the repository at this point in the history
  • Loading branch information
snakeice committed Dec 29, 2023
1 parent 9f525ff commit 3f03b16
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions pkg/db/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ func (pg *PgConnection) ReindexTable(ctx context.Context, schema, table string,
}

if initialIndexStats.PageCount < params.MINIMAL_COMPACT_PAGES {
pg.log.Warnf("skipping reindex: %s.%s, too few pages (has %d and the minimum is %d)", schema, index.IndexName, initialIndexStats.PageCount, params.MINIMAL_COMPACT_PAGES)
pg.log.Infof("skipping reindex: %s.%s, too few pages (has %d and the minimum is %d)", schema, index.IndexName, initialIndexStats.PageCount, params.MINIMAL_COMPACT_PAGES)
continue
}

if indexBloatStats.FreePerctent < params.MINIMAL_COMPACT_PERCENT {
pg.log.Warnf("skipping reindex: %s.%s, %.2f%s free space is below required %.2f%s", schema, index.IndexName, indexBloatStats.FreePerctent, "%", params.MINIMAL_COMPACT_PERCENT, "%")
if indexBloatStats.FreePerctent < params.MINIMAL_COMPACT_PERCENT*100 {
pg.log.Infof("skipping reindex: %s.%s, %.2f%s free space is below required %.2f%s", schema, index.IndexName, indexBloatStats.FreePerctent, "%", params.MINIMAL_COMPACT_PERCENT*100, "%")
continue
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/defrag/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (p *Process) process(ctx context.Context, schema, table string, attepmt int
isSkipped = true
}

if bloatStats.FreePercent < params.MINIMAL_COMPACT_PERCENT {
if bloatStats.FreePercent < params.MINIMAL_COMPACT_PERCENT*100 {
p.log.Warnf("Table %s.%s has less than %0.f%% space to compact (actual is %0.3f%%), skipping defragmentation",
schema,
table,
Expand Down Expand Up @@ -484,7 +484,7 @@ func (p *Process) process(ctx context.Context, schema, table string, attepmt int
p.log.Infof("Bloat statistics with pgstattuple: duration %s", time.Since(getStatsStart))
}

willBeSkipped := !isLocked && (isLocked || tableInfo.Stats.PageCount < params.MINIMAL_COMPACT_PAGES || bloatStats.FreePercent < params.MINIMAL_COMPACT_PERCENT)
willBeSkipped := !isLocked && (isLocked || tableInfo.Stats.PageCount < params.MINIMAL_COMPACT_PAGES || bloatStats.FreePercent < params.MINIMAL_COMPACT_PERCENT*100)

if !isLocked && (!p.NoReindex && (!isSkipped || attepmt >= params.MAX_RETRY_COUNT || (!isReindexed && !isSkipped && attepmt == 0))) {
if ok, err := p.Pg.ReindexTable(ctx, schema, table, p.Force, p.NoReindex); err != nil {
Expand Down

0 comments on commit 3f03b16

Please sign in to comment.