bloat query: fix totalwastedbytes
authorMichael Renner <[email protected]>
Wed, 3 Apr 2013 10:40:39 +0000 (12:40 +0200)
committerGreg Sabino Mullane <[email protected]>
Wed, 1 May 2013 01:05:04 +0000 (21:05 -0400)
totalwastedbytes returned only the number of wasted pages - fix that by
multiplying with the blocksize

check_postgres.pl

index d11dc5d76812dfe4c824c18ebdde9ae070d2d1c0..6482aa4073979963953479efb8cf6576ddccf145 100755 (executable)
@@ -3531,9 +3531,9 @@ SELECT
   CASE WHEN ipages < iotta THEN 0 ELSE bs*(ipages-iotta) END AS wastedibytes,
   CASE WHEN ipages < iotta THEN '0 bytes' ELSE (bs*(ipages-iotta))::bigint || ' bytes' END AS wastedisize,
   CASE WHEN relpages < otta THEN
-    CASE WHEN ipages < iotta THEN 0 ELSE ipages-iotta::bigint END
-    ELSE CASE WHEN ipages < iotta THEN relpages-otta::bigint
-      ELSE relpages-otta::bigint + ipages-iotta::bigint END
+    CASE WHEN ipages < iotta THEN 0 ELSE bs*(ipages-iotta::bigint) END
+    ELSE CASE WHEN ipages < iotta THEN bs*(relpages-otta::bigint)
+      ELSE bs*(relpages-otta::bigint + ipages-iotta::bigint) END
   END AS totalwastedbytes
 FROM (
   SELECT