Skip to content

Commit 784c714

Browse files
committed
Add per-table % reduction columns to compare-bloat output
1 parent 0bef31d commit 784c714

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

pgcopydb-helpers/compare-bloat.sh

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ TOTAL_TGT_IDX=0
148148
TABLE_COUNT=0
149149

150150
echo ""
151-
printf " ${BOLD}%-40s %10s %10s %10s %10s %10s %10s${NC}\n" \
152-
"Table" "Src Heap" "Tgt Heap" "Src TOAST" "Tgt TOAST" "Src Idx" "Tgt Idx"
153-
printf " %-40s %10s %10s %10s %10s %10s %10s\n" \
154-
"────────────────────────────────────────" "──────────" "──────────" "──────────" "──────────" "──────────" "──────────"
151+
printf " ${BOLD}%-40s %10s %10s %6s %10s %10s %6s %10s %10s %6s${NC}\n" \
152+
"Table" "Src Heap" "Tgt Heap" "Heap%" "Src TOAST" "Tgt TOAST" "TOAST%" "Src Idx" "Tgt Idx" "Idx%"
153+
printf " %-40s %10s %10s %6s %10s %10s %6s %10s %10s %6s\n" \
154+
"────────────────────────────────────────" "──────────" "──────────" "──────" "──────────" "──────────" "──────" "──────────" "──────────" "──────"
155155

156156
while IFS='|' read -r name src_heap src_toast src_idx src_rows; do
157157
[ -z "$name" ] && continue
@@ -174,19 +174,27 @@ while IFS='|' read -r name src_heap src_toast src_idx src_rows; do
174174
display_name="${display_name:0:37}..."
175175
fi
176176

177-
printf " %-40s %10s %10s %10s %10s %10s %10s\n" \
177+
heap_diff=$((src_heap - tgt_heap))
178+
toast_diff=$((src_toast - tgt_toast))
179+
idx_diff=$((src_idx - tgt_idx))
180+
181+
printf " %-40s %10s %10s %6s %10s %10s %6s %10s %10s %6s\n" \
178182
"$display_name" \
179-
"$(human_size "$src_heap")" "$(human_size "$tgt_heap")" \
180-
"$(human_size "$src_toast")" "$(human_size "$tgt_toast")" \
181-
"$(human_size "$src_idx")" "$(human_size "$tgt_idx")"
183+
"$(human_size "$src_heap")" "$(human_size "$tgt_heap")" "$(pct "$heap_diff" "$src_heap")" \
184+
"$(human_size "$src_toast")" "$(human_size "$tgt_toast")" "$(pct "$toast_diff" "$src_toast")" \
185+
"$(human_size "$src_idx")" "$(human_size "$tgt_idx")" "$(pct "$idx_diff" "$src_idx")"
182186
done <<< "$SRC_TABLES"
183187

184188
echo ""
185-
printf " ${BOLD}%-40s %10s %10s %10s %10s %10s %10s${NC}\n" \
189+
HEAP_DIFF_TOTAL=$((TOTAL_SRC_HEAP - TOTAL_TGT_HEAP))
190+
TOAST_DIFF_TOTAL=$((TOTAL_SRC_TOAST - TOTAL_TGT_TOAST))
191+
IDX_DIFF_TOTAL=$((TOTAL_SRC_IDX - TOTAL_TGT_IDX))
192+
193+
printf " ${BOLD}%-40s %10s %10s %6s %10s %10s %6s %10s %10s %6s${NC}\n" \
186194
"TOTALS ($TABLE_COUNT tables)" \
187-
"$(human_size "$TOTAL_SRC_HEAP")" "$(human_size "$TOTAL_TGT_HEAP")" \
188-
"$(human_size "$TOTAL_SRC_TOAST")" "$(human_size "$TOTAL_TGT_TOAST")" \
189-
"$(human_size "$TOTAL_SRC_IDX")" "$(human_size "$TOTAL_TGT_IDX")"
195+
"$(human_size "$TOTAL_SRC_HEAP")" "$(human_size "$TOTAL_TGT_HEAP")" "$(pct "$HEAP_DIFF_TOTAL" "$TOTAL_SRC_HEAP")" \
196+
"$(human_size "$TOTAL_SRC_TOAST")" "$(human_size "$TOTAL_TGT_TOAST")" "$(pct "$TOAST_DIFF_TOTAL" "$TOTAL_SRC_TOAST")" \
197+
"$(human_size "$TOTAL_SRC_IDX")" "$(human_size "$TOTAL_TGT_IDX")" "$(pct "$IDX_DIFF_TOTAL" "$TOTAL_SRC_IDX")"
190198

191199
# --- Section 3: Top Indexes by Size Difference ---
192200
echo ""

0 commit comments

Comments
 (0)