diff --git a/resources/checks/F004_heap_bloat.sh b/resources/checks/F004_heap_bloat.sh index a49ac98def88c106903ff5b249cfaf69159113eb..75f3d59fa327b00206fa17e943d7f481636ada9d 100755 --- a/resources/checks/F004_heap_bloat.sh +++ b/resources/checks/F004_heap_bloat.sh @@ -27,11 +27,11 @@ with data as ( sum((1 - coalesce(s.null_frac, 0)) * coalesce(s.avg_width, 1024)) as tpl_data_size, bool_or(att.atttypid = 'pg_catalog.name'::regtype) or count(att.attname) <> count(s.attname) as is_na from pg_attribute as att - join pg_class as tbl on att.attrelid = tbl.oid and tbl.relkind = 'r' + join pg_class as tbl on att.attrelid = tbl.oid /* !!!!! and tbl.relkind = 'r' */ join pg_namespace as ns on ns.oid = tbl.relnamespace - join pg_stats as s on s.schemaname = ns.nspname and s.tablename = tbl.relname and not s.inherited and s.attname = att.attname + /* !!!!! */ left join pg_stats as s on s.schemaname = ns.nspname and s.tablename = tbl.relname and not s.inherited and s.attname = att.attname left join pg_class as toast on tbl.reltoastrelid = toast.oid - where att.attnum > 0 and not att.attisdropped and s.schemaname not in ('pg_catalog', 'information_schema') and tbl.relpages > 10 + where att.attnum > 0 and not att.attisdropped /* !!!!! and s.schemaname not in ('pg_catalog', 'information_schema') and tbl.relpages > 10 */ group by 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, tbl.relhasoids order by 2, 3 ), step2 as ( @@ -115,7 +115,7 @@ with data as ( ) as "fillfactor", case when ot.table_id is not null then true else false end as overrided_settings, case - when (real_size - bloat_size)::numeric >=0 + when (real_size - bloat_size)::numeric > 0 then real_size::numeric / (real_size - bloat_size)::numeric else null end as "bloat_ratio" diff --git a/resources/checks/F005_index_bloat.sh b/resources/checks/F005_index_bloat.sh index 91757ff224444b6579cba749ea552619ceb482f0..b08f97d31ce0f89676342aa153ae4cbe1fd948b5 100755 --- a/resources/checks/F005_index_bloat.sh +++ b/resources/checks/F005_index_bloat.sh @@ -31,8 +31,8 @@ with data as ( where a.amname = 'btree' AND pg_index.indisvalid AND tbl.relkind = 'r' - AND idx.relpages > 10 - AND pg_namespace.nspname NOT IN ('pg_catalog', 'information_schema') + AND idx.relpages > 0 /* !!!!! 10 instead 0 */ + /* !!!!! AND pg_namespace.nspname NOT IN ('pg_catalog', 'information_schema') */ ), step1 as ( select i.tblid, diff --git a/resources/checks/H002_unused_indexes.sh b/resources/checks/H002_unused_indexes.sh index c1493b4068edec162ad72eb6dd0fb7bd760d812b..0b6f73ef6368d623e345227aaaa0430b6fd0cfba 100755 --- a/resources/checks/H002_unused_indexes.sh +++ b/resources/checks/H002_unused_indexes.sh @@ -16,7 +16,7 @@ with fk_indexes as ( contype = 'f' and i.indisunique is false and conkey is not null - and ci.relpages > 100 + /* !!!!! and ci.relpages > 100 */ and si.idx_scan < 10 ), table_scans as ( select relid, @@ -55,7 +55,7 @@ with fk_indexes as ( where i.indisunique = false and i.indisvalid = true - and ci.relpages > 100 + /* !!!!! and ci.relpages > 100 */ ), index_ratios as ( select i.indexrelid as index_id, @@ -168,7 +168,7 @@ index_data as ( array_to_string(indclass, ', ') as opclasses from pg_index i join pg_class ci on ci.oid = i.indexrelid and ci.relkind = 'i' - where indisvalid = true and ci.relpages > 100 + where indisvalid = true /* !!!!! and ci.relpages > 100 */ ), redundant_indexes as ( select i2.indexrelid as index_id,