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

Commit 74ad99f

Browse files
committed
f004 support Postgres 12 added
F004 report, which used pg_class.relhasoids column does not process correctly on Postgres 12. So this report was reworked to remove using of pg_class.relhasoids.
2 parents f9bfebf + bdaaf03 commit 74ad99f

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

.gitlab-ci.yml

+7
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ variables:
5858
- diff=$((f005_indexes_size - l001_indexes_size)) && diff=${diff#-} && echo $diff && ratio=$((diff * 100 / l001_indexes_size)) && echo $ratio && ([[ $ratio -gt "5" ]]) && exit 303
5959
- echo "F005/L001 Total indexes size passed"
6060
- ./checkup -c .ci/test.yml --file ./resources/checks/F004_heap_bloat.sh
61+
- data_dir=$(cat ./artifacts/test/nodes.json | jq -r '.last_check | .dir') && ([[ ! -f "./artifacts/test/json_reports/$data_dir/F004_heap_bloat.json" ]] || [[ ! -f "./artifacts/test/md_reports/$data_dir/F004.md" ]]) && exit 304
6162
- data_dir=$(cat ./artifacts/test/nodes.json | jq -r '.last_check | .dir') && msg=$(grep "can be reduced 0.00 times" ./artifacts/test/md_reports/$data_dir/F004.md) && [[ ! -z "$msg" ]] && exit 304
6263
- ([[ "$CI_COMMIT_REF_NAME" != "master" ]]) && exit 0
6364
# Check small indexes
@@ -165,6 +166,12 @@ test-check-11:
165166
services:
166167
- postgres:11
167168

169+
test-check-12:
170+
extends: ".test-check"
171+
stage: "test"
172+
services:
173+
- postgres:12
174+
168175
test-check-cli:
169176
services:
170177
- postgres:11

resources/checks/F004_heap_bloat.sh

+9-8
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ with data as (
2727
coalesce(substring(array_to_string(tbl.reloptions, ' ') from '%fillfactor=#"__#"%' for '#')::int2, 100) as fillfactor,
2828
current_setting('block_size')::numeric as bs,
2929
case when version() ~ 'mingw32|64-bit|x86_64|ppc64|ia64|amd64' then 8 else 4 end as ma, -- NS: TODO: check it
30+
3031
24 as page_hdr,
31-
23 + case when max(coalesce(null_frac, 0)) > 0 then (7 + count(*)) / 8 else 0::int end
32-
+ case when tbl.relhasoids then 4 else 0 end as tpl_hdr_size,
33-
sum((1 - coalesce(s.null_frac, 0)) * coalesce(s.avg_width, 1024)) as tpl_data_size,
32+
23 + case when max(coalesce(s.null_frac,0)) > 0 then (7 + count(s.attname)) / 8 else 0::int end
33+
+ case when bool_or(att.attname = 'oid' and att.attnum < 0) then 4 else 0 end as tpl_hdr_size,
34+
sum((1 - coalesce(s.null_frac, 0)) * coalesce(s.avg_width, 0) ) as tpl_data_size,
35+
3436
bool_or(att.atttypid = 'pg_catalog.name'::regtype) or count(att.attname) <> count(s.attname) as is_na
3537
from pg_attribute as att
3638
join pg_class as tbl on att.attrelid = tbl.oid and tbl.relkind = 'r'
@@ -42,11 +44,10 @@ with data as (
4244
and s.attname = att.attname
4345
left join pg_class as toast on tbl.reltoastrelid = toast.oid
4446
where
45-
att.attnum > 0
46-
and not att.attisdropped
47+
not att.attisdropped
4748
and (s.schemaname <> 'information_schema' or s.schemaname is null)
4849
and tbl.relpages > ${MIN_RELPAGES}
49-
group by 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, tbl.relhasoids
50+
group by 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
5051
order by 2, 3
5152
), step2 as (
5253
select
@@ -64,7 +65,7 @@ with data as (
6465
*,
6566
ceil(reltuples / ((bs - page_hdr) / tpl_size)) + ceil(toasttuples / 4) as est_tblpages,
6667
ceil(reltuples / ((bs - page_hdr) * fillfactor / (tpl_size * 100))) + ceil(toasttuples / 4) as est_tblpages_ff
67-
-- , stattuple.pgstattuple(tblid) as pst
68+
-- , tpl_hdr_size, tpl_data_size, pgstattuple(tblid) AS pst -- (DEBUG INFO)
6869
from step2
6970
), step4 as (
7071
select
@@ -86,7 +87,7 @@ with data as (
8687
then 100 * (tblpages - est_tblpages_ff) / tblpages::float
8788
else 0
8889
end as bloat_ratio
89-
-- , (pst).free_percent + (pst).dead_tuple_percent as real_frag
90+
-- , tpl_hdr_size, tpl_data_size, (pst).free_percent + (pst).dead_tuple_percent AS real_frag -- (DEBUG INFO)
9091
from step3
9192
left join pg_stat_user_tables su on su.relid = tblid
9293
-- WHERE NOT is_na

0 commit comments

Comments
 (0)