diff --git a/internal/inspect/cache/cache.go b/internal/inspect/cache/cache.go index 10c552d18..eb16a7bb4 100644 --- a/internal/inspect/cache/cache.go +++ b/internal/inspect/cache/cache.go @@ -33,10 +33,19 @@ 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 { - 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." + } + table += fmt.Sprintf("|`%s`|`%.6f`|`%s`|`%s`|\n", r.Name, r.Ratio, ok, explanation) } return list.RenderTable(table) }