Skip to content
This repository was archived by the owner on Jul 6, 2021. It is now read-only.

Commit cd34abb

Browse files
committed
F004 and F005 reports improved
1 parent bb586b1 commit cd34abb

File tree

3 files changed

+29
-15
lines changed

3 files changed

+29
-15
lines changed

pghrep/templates/F004.tpl

+4-5
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ Current database: {{ .database }}
1212
{{ if (index (index (index .results .hosts.master) "data") "heap_bloat") }}
1313
{{ if gt (len (index (index (index $.results $.hosts.master) "data") "heap_bloat")) .ROWS_LIMIT }}The list is limited to {{.ROWS_LIMIT}} items.{{ end }}
1414

15-
| \# | Table | Size | Extra | ▼ Estimated bloat | Est. bloat, bytes | Est. bloat factor | Est. bloat level, % | Live Data Size | Last vacuum | Fillfactor |
16-
|----|-------|------|-------|------------------------------|-------------------|-------------------|---------------------|----------------|-------------|------------|
15+
| \# | Table | Real Size | ▼ Estimated bloat | Est. bloat, bytes | Est. bloat factor | Est. bloat level, % | Live Data Size | Last vacuum | Fillfactor |
16+
|----|-------|------|------------------------------|-------------------|-------------------|---------------------|----------------|-------------|------------|
1717
{{ if (index (index (index .results .hosts.master) "data") "heap_bloat_total") }}| |===== TOTAL ===== |
18-
{{- if (index (index (index (index $.results $.hosts.master) "data") "heap_bloat_total") "real_size_bytes_sum") }}{{- ByteFormat (index (index (index (index $.results $.hosts.master) "data") "heap_bloat_total") "real_size_bytes_sum") 2 }}{{ end }} ||
18+
{{- if (index (index (index (index $.results $.hosts.master) "data") "heap_bloat_total") "real_size_bytes_sum") }}{{- ByteFormat (index (index (index (index $.results $.hosts.master) "data") "heap_bloat_total") "real_size_bytes_sum") 2 }}{{ end }} |
1919
{{- if (index (index (index (index $.results $.hosts.master) "data") "heap_bloat_total") "bloat_size_bytes_sum") }}{{- ByteFormat (index (index (index (index $.results $.hosts.master) "data") "heap_bloat_total") "bloat_size_bytes_sum") 2 }}{{ end }} |
2020
{{- if (index (index (index (index $.results $.hosts.master) "data") "heap_bloat_total") "bloat_size_bytes_sum") }}{{- RawIntFormat (index (index (index (index $.results $.hosts.master) "data") "heap_bloat_total") "bloat_size_bytes_sum" ) }}{{ end }} |
2121
{{- if (index (index (index (index $.results $.hosts.master) "data") "heap_bloat_total") "bloat_ratio_avg") }}{{- RawFloatFormat (index (index (index (index $.results $.hosts.master) "data") "heap_bloat_total") "bloat_ratio_avg" ) 2 }}{{ end }} |
@@ -24,14 +24,13 @@ Current database: {{ .database }}
2424
{{- $value := (index (index (index (index $.results $.hosts.master) "data") "heap_bloat") $key ) -}}
2525
|{{ $value.num }} |`{{- $key }}`{{if $value.overrided_settings}}\*{{ end }} |
2626
{{- ByteFormat ( index $value "real_size_bytes" ) 2 }} |
27-
{{- "~" }}{{ ByteFormat ( index $value "extra_size_bytes" ) 2 }} ({{- NumFormat ( index $value "extra_ratio_percent" ) 2 }}%)|
2827
{{- if ( index $value "bloat_size_bytes")}}{{ ByteFormat ( index $value "bloat_size_bytes") 2 }}{{end}} |
2928
{{- if ( index $value "bloat_size_bytes")}}{{ RawIntFormat ( index $value "bloat_size_bytes") }}{{end}} |
3029
{{- if ( index $value "bloat_ratio")}}{{ RawFloatFormat ( index $value "bloat_ratio") 2 }}{{end}} |
3130
{{- if ge (Int (index $value "Bloat ratio")) $minRatioWarning }} **{{- RawFloatFormat ( index $value "bloat_ratio_percent") 2 }}**{{else}}{{- RawFloatFormat ( index $value "bloat_ratio_percent") 2 }}{{end}} |
3231
{{- "~" }}{{ ByteFormat ( index $value "live_data_size_bytes" ) 2 }} |
3332
{{- if (index $value "last_vaccuum") }} {{ ( index $value "last_vaccuum") }} {{ end }} |
34-
{{- ( index $value "Fillfactor") }} |
33+
{{- ( index $value "fillfactor") }} |
3534
{{ end }}{{/*range*/}}
3635

3736

pghrep/templates/F005.tpl

+9-7
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,27 @@ Current database: {{ .database }}
1111
### Master (`{{.hosts.master}}`) ###
1212
{{ if gt (len (index (index (index $.results $.hosts.master) "data") "index_bloat")) .ROWS_LIMIT }}The list is limited to {{.ROWS_LIMIT}} items.{{ end }}
1313

14-
| \# | Index (Table) | Table Size |Index Size | Extra | ▼ Estimated bloat | Est. bloat, bytes | Est. bloat level, % | Live Data Size | Fillfactor |
15-
|----|---------------|------------|-----------|-------|------------------------------|-------------------|---------------------|----------------|-------------|
14+
| \# | Index (Table) | Index Size | Table Size | ▼ Estimated bloat | Est. bloat, bytes | Est. bloat factor |Est. bloat level, % | Live Data Size | Fillfactor |
15+
|----|---------------|------------|------------|------------------------------|-------------------|-------------------|--------------------|----------------|-------------|
1616
| |===== TOTAL ===== |
17+
{{- ByteFormat (index (index (index (index $.results $.hosts.master) "data") "index_bloat_total") "real_size_bytes_sum" ) 2 }} |
1718
{{- ByteFormat (index (index (index (index $.results $.hosts.master) "data") "index_bloat_total") "table_size_bytes_sum" ) 2 }} |
18-
{{- ByteFormat (index (index (index (index $.results $.hosts.master) "data") "index_bloat_total") "real_size_bytes_sum" ) 2 }} ||
1919
{{- ByteFormat (index (index (index (index $.results $.hosts.master) "data") "index_bloat_total") "bloat_size_bytes_sum" ) 2 }} |
2020
{{- RawIntFormat (index (index (index (index $.results $.hosts.master) "data") "index_bloat_total") "bloat_size_bytes_sum" ) }}|
21-
{{- if ge (Int (index (index (index (index $.results $.hosts.master) "data") "index_bloat_total") "bloat_ratio_percent_avg" )) $minRatioWarning }}**{{- RawFloatFormat (index (index (index (index $.results $.hosts.master) "data") "index_bloat_total") "bloat_ratio_percent_avg" ) 2 }}**{{else}}{{- RawFloatFormat (index (index (index (index $.results $.hosts.master) "data") "index_bloat_total") "bloat_ratio_percent_avg" ) 2 }}{{end}}|||
21+
{{- if (index (index (index (index $.results $.hosts.master) "data") "index_bloat_total") "bloat_ratio_avg") }}{{- RawFloatFormat (index (index (index (index $.results $.hosts.master) "data") "index_bloat_total") "bloat_ratio_avg" ) 2 }}{{ end }} |
22+
{{- if ge (Int (index (index (index (index $.results $.hosts.master) "data") "index_bloat_total") "bloat_ratio_percent_avg" )) $minRatioWarning }}**{{- RawFloatFormat (index (index (index (index $.results $.hosts.master) "data") "index_bloat_total") "bloat_ratio_percent_avg" ) 2 }}**{{else}}{{- RawFloatFormat (index (index (index (index $.results $.hosts.master) "data") "index_bloat_total") "bloat_ratio_percent_avg" ) 2 }}{{end}}|
23+
{{- ByteFormat (index (index (index (index $.results $.hosts.master) "data") "index_bloat_total") "live_data_size_bytes_sum" ) 2 }} |||
2224
{{ range $i, $key := (index (index (index (index .results .hosts.master) "data") "index_bloat") "_keys") }}
2325
{{- $value := (index (index (index (index $.results $.hosts.master) "data") "index_bloat") $key) -}}
2426
{{- $tableIndex := Split $key "\n" -}}|{{ $value.num }} |
2527
{{- $table := Trim (index $tableIndex 1) " ()"}}`{{ (index $tableIndex 0) }}` (`{{ $table }}`{{if $value.overrided_settings}}\*{{ end }}) |
26-
{{- ByteFormat ( index $value "table_size_bytes") 2 }} |
2728
{{- ByteFormat ( index $value "real_size_bytes") 2 }} |
28-
{{- if ( index $value "extra_size_bytes")}}{{- "~" }}{{ ByteFormat ( index $value "extra_size_bytes" ) 2 }} ({{- NumFormat ( index $value "extra_ratio_percent" ) 2 }}%){{end}} |
29+
{{- ByteFormat ( index $value "table_size_bytes") 2 }} |
2930
{{- if ( index $value "bloat_size_bytes")}}{{ ByteFormat ( index $value "bloat_size_bytes") 2 }}{{end}} |
3031
{{- if ( index $value "bloat_size_bytes")}}{{ RawIntFormat ( index $value "bloat_size_bytes") }}{{end}} |
32+
{{- if ( index $value "bloat_ratio")}}{{ RawFloatFormat ( index $value "bloat_ratio") 2 }}{{end}} |
3133
{{- if ge (Int (index $value "bloat_ratio_percent")) $minRatioWarning }} **{{- RawFloatFormat ( index $value "bloat_ratio_percent") 2 }}**{{else}}{{- RawFloatFormat ( index $value "bloat_ratio_percent") 2 }}{{end}} |
32-
{{- "~" }}{{ ByteFormat ( index $value "live_bytes" ) 2 }} |
34+
{{- "~" }}{{ ByteFormat ( index $value "live_data_size_bytes" ) 2 }} |
3335
{{- ( index $value "fillfactor") }} |
3436
{{ end }}
3537
{{- if gt (Int (index (index (index .results .hosts.master) "data") "overrided_settings_count")) 0 }}

resources/checks/F005_index_bloat.sh

+16-3
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ with data as (
123123
) as "index_table_name",
124124
real_size as "real_size_bytes",
125125
pg_size_pretty(real_size::numeric) as "size",
126+
case
127+
when (real_size - bloat_size)::numeric >=0
128+
then real_size::numeric / (real_size - bloat_size)::numeric
129+
else null
130+
end as "bloat_ratio",
126131
extra_ratio as "extra_ratio_percent",
127132
case
128133
when extra_size::numeric >= 0
@@ -153,7 +158,12 @@ with data as (
153158
when (real_size - bloat_size)::numeric >=0
154159
then '~' || pg_size_pretty((real_size - bloat_size)::numeric)
155160
else null
156-
end as "live",
161+
end as "live_data_size",
162+
case
163+
when (real_size - bloat_size)::numeric >=0
164+
then (real_size - bloat_size)::numeric
165+
else null
166+
end as "live_data_size_bytes",
157167
case
158168
when (real_size - bloat_size)::numeric >=0
159169
then (real_size - bloat_size)::numeric
@@ -180,9 +190,12 @@ with data as (
180190
sum("extra_size_bytes") as "extra_size_bytes_sum",
181191
sum("real_size_bytes") as "real_size_bytes_sum",
182192
sum("bloat_size_bytes") as "bloat_size_bytes_sum",
183-
(sum("bloat_size_bytes")::numeric/sum("real_size_bytes")::numeric * 100) as "bloat_ratio_percent_avg",
193+
(sum("real_size_bytes")::numeric/sum("live_data_size_bytes")::numeric) as "bloat_ratio_avg",
194+
(sum("bloat_size_bytes")::numeric/sum("real_size_bytes")::numeric * 100) as "bloat_ratio_percent_avg",
184195
sum("extra_size_bytes") as "extra_size_bytes_sum",
185-
sum("table_size_bytes") as "table_size_bytes_sum"
196+
sum("table_size_bytes") as "table_size_bytes_sum",
197+
sum("live_data_size_bytes") as "live_data_size_bytes_sum"
198+
186199
from data
187200
)
188201
select

0 commit comments

Comments
 (0)