summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Sabino Mullane2012-05-28 15:11:44 +0000
committerGreg Sabino Mullane2012-05-28 15:11:44 +0000
commit61a1e65e67d3c89ea302c85fd33640142f4d6dc2 (patch)
tree0f32fc78dd9bc2daa530d4ddbf167a9d73d463ac
parent8171cd601969695c10ade08f4a087d2dc71b7a20 (diff)
parent84972b37dee19a9f9905ee1baea6d0ce34284694 (diff)
Merge remote branch 'f0rk/f0rk/empty_tables_bloat'
-rwxr-xr-xcheck_postgres.pl19
1 files changed, 13 insertions, 6 deletions
diff --git a/check_postgres.pl b/check_postgres.pl
index 70254c6c2..d209097cb 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -3535,12 +3535,20 @@ SELECT
END AS totalwastedbytes
FROM (
SELECT
- schemaname, tablename, cc.reltuples, cc.relpages, bs,
- CEIL((cc.reltuples*((datahdr+ma-
- (CASE WHEN datahdr%ma=0 THEN ma ELSE datahdr%ma END))+nullhdr2+4))/(bs-20::float)) AS otta,
+ nn.nspname AS schemaname,
+ cc.relname AS tablename,
+ COALESCE(cc.reltuples,0) AS reltuples,
+ COALESCE(cc.relpages,0) AS relpages,
+ COALESCE(bs,0) AS bs,
+ COALESCE(CEIL((cc.reltuples*((datahdr+ma-
+ (CASE WHEN datahdr%ma=0 THEN ma ELSE datahdr%ma END))+nullhdr2+4))/(bs-20::float)),0) AS otta,
COALESCE(c2.relname,'?') AS iname, COALESCE(c2.reltuples,0) AS ituples, COALESCE(c2.relpages,0) AS ipages,
COALESCE(CEIL((c2.reltuples*(datahdr-12))/(bs-20::float)),0) AS iotta -- very rough approximation, assumes all cols
- FROM (
+ FROM
+ pg_class cc
+ JOIN pg_namespace nn ON cc.relnamespace = nn.oid AND nn.nspname <> 'information_schema'
+ LEFT JOIN
+ (
SELECT
ma,bs,schemaname,tablename,
(datawidth+(hdr+ma-(case when hdr%ma=0 THEN ma ELSE hdr%ma END)))::numeric AS datahdr,
@@ -3566,8 +3574,7 @@ FROM (
GROUP BY 1,2,3,4,5
) AS foo
) AS rs
- JOIN pg_class cc ON cc.relname = rs.tablename
- JOIN pg_namespace nn ON cc.relnamespace = nn.oid AND nn.nspname = rs.schemaname AND nn.nspname <> 'information_schema'
+ ON cc.relname = rs.tablename AND nn.nspname = rs.schemaname
LEFT JOIN pg_index i ON indrelid = cc.oid
LEFT JOIN pg_class c2 ON c2.oid = i.indexrelid
) AS sml