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

Commit d232736

Browse files
committed
F007 Table sizes check
1 parent d818af0 commit d232736

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

pghrep/templates/F007.tpl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# {{ .checkId }} Table sizes #
2+
3+
## Observations ##
4+
{{ if .hosts.master }}
5+
### Master (`{{.hosts.master}}`) ###
6+
Table | Rows | Total size | Table size | Index(es) Size | TOAST Size
7+
------|------|------------|------------|----------------|------------
8+
{{ range $i, $key := (index (index (index .results .hosts.master) "data") "_keys") }}
9+
{{- $value := (index (index (index $.results $.hosts.master) "data") $key) -}}
10+
{{ index $value "Table"}} | {{ index $value "Rows"}} | {{ index $value "Total Size"}} | {{ index $value "Table Size"}} | {{ index $value "Index(es) Size"}} | {{ index $value "TOAST Size"}}
11+
{{ end }}
12+
{{- end -}}
13+
{{ if gt (len .hosts.replicas) 0 }}
14+
### Replica servers: ###
15+
{{ range $skey, $host := .hosts.replicas }}
16+
#### Replica (`{{ $host }}`) ####
17+
{{ if (index $.results $host) }}
18+
Table | Rows | Total size | Table size | Index(es) Size | TOAST Size
19+
------|------|------------|------------|----------------|------------
20+
{{ range $i, $key := (index (index (index $.results $host) "data") "_keys") }}
21+
{{- $value := (index (index (index $.results $host) "data") $key) -}}
22+
{{ index $value "Table"}} | {{ index $value "Rows"}} | {{ index $value "Total Size"}} | {{ index $value "Table Size"}} | {{ index $value "Index(es) Size"}} | {{ index $value "TOAST Size"}}
23+
{{ end }}
24+
{{- else -}}
25+
No data
26+
{{- end -}}{{ end }}{{ end }}
27+
28+
## Conclusions ##
29+
30+
31+
## Recommendations ##
32+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Collect pg cluster info
2+
main_sql=$(curl -s -L https://raw.githubusercontent.com/NikolayS/postgres_dba/4.0/sql/2_table_sizes.sql | awk '{gsub("; *$", "", $0); print $0}')
3+
4+
#psql -U postila_ru -t -0 -f - <<SQL
5+
${CHECK_HOST_CMD} "${_PSQL} -f - " <<SQL
6+
with data as (
7+
$main_sql
8+
)
9+
select json_object_agg(data."Table", data) as json from data where data."Table" not like ' '
10+
SQL

0 commit comments

Comments
 (0)