Skip to content

Commit

Permalink
add explanation for cache hit and if action is needed
Browse files Browse the repository at this point in the history
  • Loading branch information
encima committed Apr 10, 2024
1 parent ad8fa27 commit 76428d5
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions internal/inspect/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,22 @@ func Run(ctx context.Context, config pgconn.Config, fsys afero.Fs, options ...fu
return err
}
// TODO: implement a markdown table marshaller
table := "|Name|Ratio|\n|-|-|\n"
table := "|Name|Ratio|OK?|Explanation|\n|-|-|-|-|\n"
for _, r := range result {

Check failure on line 37 in internal/inspect/cache/cache.go

View workflow job for this annotation

GitHub Actions / Lint

unnecessary leading newline (whitespace)
table += fmt.Sprintf("|`%s`|`%.6f`|\n", r.Name, r.Ratio)

ok := "Yup!"
if r.Ratio < 0.94 {
ok = "Maybe not..."
}
var explanation string
if r.Name == "index hit rate" {
explanation = "This is the ratio of index hits to index scans. If this ratio is low, it means that the database is not using indexes effectively. Check the `index-usage` command for more info."
} else if r.Name == "table hit rate" {
explanation = "This is the ratio of table hits to table scans. If this ratio is low, it means that your queries are not finding the data effectively. Check your query performance and it might be worth increasing your compute."

}

Check failure on line 49 in internal/inspect/cache/cache.go

View workflow job for this annotation

GitHub Actions / Lint

unnecessary trailing newline (whitespace)

table += fmt.Sprintf("|`%s`|`%.6f`|`%s`|`%s`|\n", r.Name, r.Ratio, ok, explanation)

}

Check failure on line 53 in internal/inspect/cache/cache.go

View workflow job for this annotation

GitHub Actions / Lint

unnecessary trailing newline (whitespace)
return list.RenderTable(table)
Expand Down

0 comments on commit 76428d5

Please sign in to comment.