postgresai 0.18.1-rc.2 → 0.18.1-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/postgres-ai.js +237 -77
- package/package.json +1 -1
- package/schemas/F004.schema.json +52 -2
- package/schemas/G001.schema.json +65 -3
- package/schemas/G003.schema.json +128 -1
- package/schemas/H001.schema.json +41 -2
package/dist/bin/postgres-ai.js
CHANGED
|
@@ -13538,7 +13538,7 @@ var {
|
|
|
13538
13538
|
// package.json
|
|
13539
13539
|
var package_default = {
|
|
13540
13540
|
name: "postgresai",
|
|
13541
|
-
version: "0.18.1-rc.
|
|
13541
|
+
version: "0.18.1-rc.4",
|
|
13542
13542
|
description: "postgres_ai CLI",
|
|
13543
13543
|
license: "Apache-2.0",
|
|
13544
13544
|
private: false,
|
|
@@ -16898,7 +16898,7 @@ var Result = import_lib.default.Result;
|
|
|
16898
16898
|
var TypeOverrides = import_lib.default.TypeOverrides;
|
|
16899
16899
|
var defaults = import_lib.default.defaults;
|
|
16900
16900
|
// package.json
|
|
16901
|
-
var version = "0.18.1-rc.
|
|
16901
|
+
var version = "0.18.1-rc.4";
|
|
16902
16902
|
var package_default2 = {
|
|
16903
16903
|
name: "postgresai",
|
|
16904
16904
|
version,
|
|
@@ -40569,23 +40569,12 @@ where
|
|
|
40569
40569
|
description: "This metric identifies invalid indexes in the database with decision tree data for remediation. It provides insights into whether to DROP (if duplicate exists), RECREATE (if backs constraint), or flag as UNCERTAIN (if additional RCA is needed to check query plans). Decision tree: 1) Valid duplicate exists -> DROP, 2) Backs PK/UNIQUE constraint -> RECREATE, 3) Table < 10K rows -> RECREATE (small tables rebuild quickly, typically under 1 second), 4) Otherwise -> UNCERTAIN (need query plan analysis to assess impact). Adapts the top-N + `'$other$'` bucket pattern from !262 to this metric: ranks invalid indexes by `index_size_bytes desc` (ties broken by schema, table, then index name for stability), keeps the top 100, and folds the tail into a single `'$other$'` row whose `index_size_bytes` / `table_row_estimate` are summed and whose tag columns carry the literal `'$other$'` sentinel. The `'$other$'` row is omitted entirely (via `HAVING count(*) > 0`) when all invalid indexes fit within the top-100 cap, so its absence on healthy clusters is normal. System schemas (`pg_catalog`, `information_schema`, `pg_toast`, `pg_temp_*`, `pg_toast_temp_*`) are excluded: their indexes cannot be dropped and must never be recommended for removal.",
|
|
40570
40570
|
sqls: {
|
|
40571
40571
|
11: `with fk_indexes as materialized ( /* pgwatch_generated */
|
|
40572
|
-
|
|
40573
|
-
|
|
40574
|
-
|
|
40575
|
-
|
|
40576
|
-
|
|
40577
|
-
|
|
40578
|
-
array_to_string(indclass, ', ') as opclasses
|
|
40579
|
-
from pg_stat_all_indexes
|
|
40580
|
-
join pg_index using (indexrelid)
|
|
40581
|
-
left join pg_constraint
|
|
40582
|
-
on array_to_string(indkey, ',') = array_to_string(conkey, ',')
|
|
40583
|
-
and schemaname = (connamespace::regnamespace)::text
|
|
40584
|
-
and conrelid = relid
|
|
40585
|
-
and contype = 'f'
|
|
40586
|
-
where idx_scan = 0
|
|
40587
|
-
and indisunique is false
|
|
40588
|
-
and conkey is not null
|
|
40572
|
+
-- An index backs a foreign key when the key is on the index's own table
|
|
40573
|
+
-- and the key's columns are the index's leading columns (#476).
|
|
40574
|
+
select distinct i.indexrelid
|
|
40575
|
+
from pg_index i
|
|
40576
|
+
join pg_constraint c on c.conrelid = i.indrelid and c.contype = 'f'
|
|
40577
|
+
where (string_to_array(i.indkey::text, ' ')::int2[])[1:cardinality(c.conkey)] @> c.conkey
|
|
40589
40578
|
),
|
|
40590
40579
|
-- Find valid indexes that could be duplicates (same table, same columns)
|
|
40591
40580
|
valid_duplicates as (
|
|
@@ -40612,6 +40601,13 @@ data as (
|
|
|
40612
40601
|
-- Constraint info
|
|
40613
40602
|
pidx.indisprimary as is_pk,
|
|
40614
40603
|
pidx.indisunique as is_unique,
|
|
40604
|
+
-- H001-O1: false = writes do not maintain it (the build failed before its first scan ended)
|
|
40605
|
+
pidx.indisready as is_ready,
|
|
40606
|
+
-- H001-O2 / §9: an index whose concurrent build is still running reads invalid too
|
|
40607
|
+
exists (
|
|
40608
|
+
select from pg_stat_progress_create_index as p
|
|
40609
|
+
where p.index_relid = pidx.indexrelid
|
|
40610
|
+
) as build_in_progress,
|
|
40615
40611
|
con.conname as constraint_name,
|
|
40616
40612
|
-- Table row estimate
|
|
40617
40613
|
pct.reltuples::bigint as table_row_estimate,
|
|
@@ -40620,12 +40616,7 @@ data as (
|
|
|
40620
40616
|
vd.valid_index_name,
|
|
40621
40617
|
vd.valid_index_definition,
|
|
40622
40618
|
-- FK support check
|
|
40623
|
-
((
|
|
40624
|
-
select count(1)
|
|
40625
|
-
from fk_indexes fi
|
|
40626
|
-
where fi.fk_table_ref = pct.relname
|
|
40627
|
-
and fi.opclasses like (array_to_string(pidx.indclass, ', ') || '%')
|
|
40628
|
-
) > 0)::int as supports_fk
|
|
40619
|
+
(exists (select from fk_indexes fi where fi.indexrelid = pidx.indexrelid))::int as supports_fk
|
|
40629
40620
|
from pg_index pidx
|
|
40630
40621
|
join pg_class pci on pci.oid = pidx.indexrelid
|
|
40631
40622
|
join pg_class pct on pct.oid = pidx.indrelid
|
|
@@ -40660,6 +40651,8 @@ select
|
|
|
40660
40651
|
index_size_bytes,
|
|
40661
40652
|
is_pk,
|
|
40662
40653
|
is_unique,
|
|
40654
|
+
is_ready,
|
|
40655
|
+
build_in_progress,
|
|
40663
40656
|
constraint_name,
|
|
40664
40657
|
table_row_estimate,
|
|
40665
40658
|
has_valid_duplicate,
|
|
@@ -40681,6 +40674,8 @@ select
|
|
|
40681
40674
|
coalesce(sum(index_size_bytes), 0)::int8 as index_size_bytes,
|
|
40682
40675
|
false as is_pk,
|
|
40683
40676
|
false as is_unique,
|
|
40677
|
+
bool_and(is_ready) as is_ready,
|
|
40678
|
+
bool_or(build_in_progress) as build_in_progress,
|
|
40684
40679
|
'$other$'::text as constraint_name,
|
|
40685
40680
|
coalesce(sum(table_row_estimate), 0)::bigint as table_row_estimate,
|
|
40686
40681
|
bool_or(has_valid_duplicate) as has_valid_duplicate,
|
|
@@ -40700,24 +40695,12 @@ having count(*) > 0;
|
|
|
40700
40695
|
description: "This metric identifies unused indexes in the database. It provides insights into the number of unused indexes and their details. This metric helps administrators identify and fix unused indexes to improve database performance. Adapts the top-N + `'$other$'` bucket pattern from !262 to this metric: within the `idx_scan = 0 AND idx_is_btree` filter, ranks indexes by `index_size_bytes desc` (ties broken by schema, table, index name), keeps the top 100, and folds the tail into a single `'$other$'` row. Counter columns (`idx_scan`, `all_scans`, `writes`, `index_size_bytes`, `table_size_bytes`, `relpages`) are summed across the tail; ratio columns (`index_scan_pct`, `scans_per_write`) and the `supports_fk` boolean are deliberately zeroed/false on the aggregate row because the tail-level average would mislead and the per-row FK relationship has no meaningful aggregate. Tag columns carry the literal `'$other$'` sentinel. The `'$other$'` row is omitted entirely (via `HAVING count(*) > 0`) when ≤100 indexes match the unused filter. System schemas (`pg_catalog`, `information_schema`, `pg_toast`, `pg_temp_*`, `pg_toast_temp_*`) are excluded: their indexes cannot be dropped and must never be recommended for removal.",
|
|
40701
40696
|
sqls: {
|
|
40702
40697
|
11: `with fk_indexes as materialized ( /* pgwatch_generated */
|
|
40703
|
-
|
|
40704
|
-
|
|
40705
|
-
|
|
40706
|
-
cr.relname as table_name,
|
|
40707
|
-
(confrelid::regclass)::text as fk_table_ref,
|
|
40708
|
-
array_to_string(indclass, ', ') as opclasses
|
|
40698
|
+
-- An index backs a foreign key when the key is on the index's own table
|
|
40699
|
+
-- and the key's columns are the index's leading columns (#476).
|
|
40700
|
+
select distinct i.indexrelid
|
|
40709
40701
|
from pg_index i
|
|
40710
|
-
join
|
|
40711
|
-
|
|
40712
|
-
join pg_namespace n on n.oid = ci.relnamespace
|
|
40713
|
-
join pg_constraint cn on cn.conrelid = cr.oid
|
|
40714
|
-
left join pg_stat_all_indexes as si on si.indexrelid = i.indexrelid
|
|
40715
|
-
where
|
|
40716
|
-
contype = 'f'
|
|
40717
|
-
and i.indisunique is false
|
|
40718
|
-
and conkey is not null
|
|
40719
|
-
and ci.relpages > 5
|
|
40720
|
-
and si.idx_scan < 10
|
|
40702
|
+
join pg_constraint c on c.conrelid = i.indrelid and c.contype = 'f'
|
|
40703
|
+
where (string_to_array(i.indkey::text, ' ')::int2[])[1:cardinality(c.conkey)] @> c.conkey
|
|
40721
40704
|
), table_scans as (
|
|
40722
40705
|
select relid,
|
|
40723
40706
|
tables.idx_scan + tables.seq_scan as all_scans,
|
|
@@ -40769,13 +40752,7 @@ having count(*) > 0;
|
|
|
40769
40752
|
i.relpages,
|
|
40770
40753
|
idx_is_btree,
|
|
40771
40754
|
i.opclasses,
|
|
40772
|
-
(
|
|
40773
|
-
select count(1)
|
|
40774
|
-
from fk_indexes fi
|
|
40775
|
-
where fi.fk_table_ref = i.table_name
|
|
40776
|
-
and fi.schema_name = i.schema_name
|
|
40777
|
-
and fi.opclasses like (i.opclasses || '%')
|
|
40778
|
-
) > 0 as supports_fk
|
|
40755
|
+
exists (select from fk_indexes fi where fi.indexrelid = i.indexrelid) as supports_fk
|
|
40779
40756
|
from indexes i
|
|
40780
40757
|
join table_scans ts on ts.relid = i.indrelid
|
|
40781
40758
|
)
|
|
@@ -40844,24 +40821,12 @@ having count(*) > 0;
|
|
|
40844
40821
|
description: "This metric identifies redundant indexes that can potentially be dropped to save storage space and improve write performance. It analyzes index relationships and finds indexes that are covered by other indexes, considering column order, operator classes, and foreign key constraints. Uses the exact logic from tmp.sql with JSON aggregation and proper thresholds. Adapts the top-N + `'$other$'` bucket pattern from !262 to this metric: ranks redundant indexes by `index_size_bytes desc` (ties broken by `table_name`), keeps the top 100, and folds the tail into a single `'$other$'` row whose `table_size_bytes`, `index_size_bytes` and `index_usage` columns are summed and whose tag columns carry the literal `'$other$'` sentinel. The `redundant_indexes_grouped` CTE intentionally preserves duplicate column aliases (`tag_schema_name` / `tag_index_name` appear twice — once from the raw name and once from the `formated_*` variant) because the dashboards rely on both spellings; the duplication is preserved on the `'$other$'` row for consistency. The `'$other$'` row is omitted entirely (via `HAVING count(*) > 0`) when there are ≤100 redundant pairs, so its absence on healthy clusters is normal. System schemas (`pg_catalog`, `information_schema`, `pg_toast`, `pg_temp_*`, `pg_toast_temp_*`) are excluded: their indexes cannot be dropped and must never be recommended for removal.",
|
|
40845
40822
|
sqls: {
|
|
40846
40823
|
11: `with fk_indexes as materialized ( /* pgwatch_generated */
|
|
40847
|
-
|
|
40848
|
-
|
|
40849
|
-
|
|
40850
|
-
cr.relname as table_name,
|
|
40851
|
-
(confrelid::regclass)::text as fk_table_ref,
|
|
40852
|
-
array_to_string(indclass, ', ') as opclasses
|
|
40824
|
+
-- An index backs a foreign key when the key is on the index's own table
|
|
40825
|
+
-- and the key's columns are the index's leading columns (#476).
|
|
40826
|
+
select distinct i.indexrelid
|
|
40853
40827
|
from pg_index i
|
|
40854
|
-
join
|
|
40855
|
-
|
|
40856
|
-
join pg_namespace n on n.oid = ci.relnamespace
|
|
40857
|
-
join pg_constraint cn on cn.conrelid = cr.oid
|
|
40858
|
-
left join pg_stat_all_indexes as si on si.indexrelid = i.indexrelid
|
|
40859
|
-
where
|
|
40860
|
-
contype = 'f'
|
|
40861
|
-
and i.indisunique is false
|
|
40862
|
-
and conkey is not null
|
|
40863
|
-
and ci.relpages > 5
|
|
40864
|
-
and si.idx_scan < 10
|
|
40828
|
+
join pg_constraint c on c.conrelid = i.indrelid and c.contype = 'f'
|
|
40829
|
+
where (string_to_array(i.indkey::text, ' ')::int2[])[1:cardinality(c.conkey)] @> c.conkey
|
|
40865
40830
|
),
|
|
40866
40831
|
-- Redundant indexes
|
|
40867
40832
|
index_data as (
|
|
@@ -40913,8 +40878,10 @@ index_data as (
|
|
|
40913
40878
|
not i2.indisprimary -- index 1 is not primary
|
|
40914
40879
|
and not i2.indisunique -- index 1 is not unique (unique indexes serve constraint purpose)
|
|
40915
40880
|
and am1.amname = am2.amname -- same access type
|
|
40916
|
-
|
|
40917
|
-
|
|
40881
|
+
-- index 2's columns and opclasses are a leading prefix of index 1's;
|
|
40882
|
+
-- the trailing separator keeps column 1 from matching column 12 (#482)
|
|
40883
|
+
and (i1.columns || ' ') like (i2.columns || ' %')
|
|
40884
|
+
and (i1.opclasses || ', ') like (i2.opclasses || ', %')
|
|
40918
40885
|
-- index expressions is same
|
|
40919
40886
|
and pg_get_expr(i1.indexprs, i1.indrelid) is not distinct from pg_get_expr(i2.indexprs, i2.indrelid)
|
|
40920
40887
|
-- index predicates is same
|
|
@@ -40925,13 +40892,7 @@ index_data as (
|
|
|
40925
40892
|
), redundant_indexes_fk as (
|
|
40926
40893
|
select
|
|
40927
40894
|
ri.*,
|
|
40928
|
-
((
|
|
40929
|
-
select count(1)
|
|
40930
|
-
from fk_indexes fi
|
|
40931
|
-
where
|
|
40932
|
-
fi.fk_table_ref = ri.table_name
|
|
40933
|
-
and fi.opclasses like (ri.opclasses || '%')
|
|
40934
|
-
) > 0)::int as supports_fk
|
|
40895
|
+
(exists (select from fk_indexes fi where fi.indexrelid = ri.index_id))::int as supports_fk
|
|
40935
40896
|
from redundant_indexes ri
|
|
40936
40897
|
),
|
|
40937
40898
|
-- Cut recursive links
|
|
@@ -43065,6 +43026,14 @@ var CHECKUP_DICTIONARY_DATA = [
|
|
|
43065
43026
|
category: "system",
|
|
43066
43027
|
sort_order: null,
|
|
43067
43028
|
is_system_report: false
|
|
43029
|
+
},
|
|
43030
|
+
{
|
|
43031
|
+
code: "W001",
|
|
43032
|
+
title: "Weekly overview",
|
|
43033
|
+
description: "Database load and top queries over the last week, and the three most important actions",
|
|
43034
|
+
category: "monitoring",
|
|
43035
|
+
sort_order: null,
|
|
43036
|
+
is_system_report: false
|
|
43068
43037
|
}
|
|
43069
43038
|
];
|
|
43070
43039
|
|
|
@@ -43799,7 +43768,9 @@ async function getInvalidIndexes(client, pgMajorVersion = 16) {
|
|
|
43799
43768
|
table_row_estimate: parseInt(String(transformed.table_row_estimate || 0), 10),
|
|
43800
43769
|
has_valid_duplicate: toBool(transformed.has_valid_duplicate),
|
|
43801
43770
|
valid_duplicate_name: transformed.valid_index_name ? String(transformed.valid_index_name) : null,
|
|
43802
|
-
valid_duplicate_definition: transformed.valid_index_definition ? String(transformed.valid_index_definition) : null
|
|
43771
|
+
valid_duplicate_definition: transformed.valid_index_definition ? String(transformed.valid_index_definition) : null,
|
|
43772
|
+
...transformed.is_ready !== undefined ? { is_ready: toBool(transformed.is_ready) } : {},
|
|
43773
|
+
...transformed.build_in_progress !== undefined ? { build_in_progress: toBool(transformed.build_in_progress) } : {}
|
|
43803
43774
|
};
|
|
43804
43775
|
}).filter((index) => !isSystemSchema(index.schema_name));
|
|
43805
43776
|
}
|
|
@@ -45762,6 +45733,194 @@ async function generateG001(client, nodeName) {
|
|
|
45762
45733
|
};
|
|
45763
45734
|
return report;
|
|
45764
45735
|
}
|
|
45736
|
+
var G003_TIMEOUT_SETTINGS = [
|
|
45737
|
+
"statement_timeout",
|
|
45738
|
+
"transaction_timeout",
|
|
45739
|
+
"lock_timeout",
|
|
45740
|
+
"idle_in_transaction_session_timeout",
|
|
45741
|
+
"idle_session_timeout",
|
|
45742
|
+
"deadlock_timeout",
|
|
45743
|
+
"log_lock_waits"
|
|
45744
|
+
];
|
|
45745
|
+
var G003_MAX_ROLES = 60;
|
|
45746
|
+
var G003_MAX_ROUTINES = 30;
|
|
45747
|
+
var G003_QUERY_CHARS = 120;
|
|
45748
|
+
var G003_ROLES_SQL = `
|
|
45749
|
+
select r.rolname as role, r.rolcanlogin as can_login, r.rolsuper as superuser, r.rolbypassrls as bypass_rls,
|
|
45750
|
+
coalesce((select array_agg(g.rolname::text order by g.rolname)
|
|
45751
|
+
from pg_auth_members as m join pg_roles as g on g.oid = m.roleid
|
|
45752
|
+
where m.member = r.oid), '{}') as member_of,
|
|
45753
|
+
(select s.setconfig from pg_db_role_setting as s
|
|
45754
|
+
where s.setrole = r.oid and s.setdatabase = 0) as config
|
|
45755
|
+
from pg_roles as r
|
|
45756
|
+
where r.rolname !~ '^pg_'
|
|
45757
|
+
order by r.rolname
|
|
45758
|
+
`;
|
|
45759
|
+
var G003_ROLE_DATABASE_SQL = `
|
|
45760
|
+
select r.rolname as role, d.datname as database, s.setconfig as config
|
|
45761
|
+
from pg_db_role_setting as s
|
|
45762
|
+
join pg_roles as r on r.oid = s.setrole
|
|
45763
|
+
join pg_database as d on d.oid = s.setdatabase
|
|
45764
|
+
order by r.rolname, d.datname
|
|
45765
|
+
`;
|
|
45766
|
+
var G003_DATABASE_SQL = `
|
|
45767
|
+
select d.datname as database, s.setconfig as config
|
|
45768
|
+
from pg_db_role_setting as s
|
|
45769
|
+
join pg_database as d on d.oid = s.setdatabase
|
|
45770
|
+
where s.setrole = 0
|
|
45771
|
+
order by d.datname
|
|
45772
|
+
`;
|
|
45773
|
+
var G003_SERVER_SQL = `
|
|
45774
|
+
select name, reset_val as setting, coalesce(unit, '') as unit, source
|
|
45775
|
+
from pg_settings
|
|
45776
|
+
where name = any($1)
|
|
45777
|
+
order by name
|
|
45778
|
+
`;
|
|
45779
|
+
var G003_PGSS_SCHEMA_SQL = `
|
|
45780
|
+
select n.nspname as schema
|
|
45781
|
+
from pg_extension as e join pg_namespace as n on n.oid = e.extnamespace
|
|
45782
|
+
where e.extname = 'pg_stat_statements'
|
|
45783
|
+
`;
|
|
45784
|
+
var g003CallsSql = (quotedSchema) => `
|
|
45785
|
+
with s as (
|
|
45786
|
+
select p.userid, p.queryid, p.calls, p.query,
|
|
45787
|
+
coalesce((to_jsonb(p) ->> 'max_exec_time'), (to_jsonb(p) ->> 'max_time'))::float8 as max_ms,
|
|
45788
|
+
coalesce(to_jsonb(p) ->> 'minmax_stats_since', to_jsonb(p) ->> 'stats_since') as since
|
|
45789
|
+
from ${quotedSchema}.pg_stat_statements as p
|
|
45790
|
+
)
|
|
45791
|
+
select r.rolname as role, sum(s.calls)::bigint as calls,
|
|
45792
|
+
(array_agg(s.max_ms order by s.max_ms desc nulls last))[1] as longest_ms,
|
|
45793
|
+
(array_agg(s.queryid::text order by s.max_ms desc nulls last))[1] as longest_queryid,
|
|
45794
|
+
-- Utility text stays verbatim in pg_stat_statements, passwords included: only plain queries.
|
|
45795
|
+
(array_agg(case when s.query ~* '^\\s*(insert|update|delete|merge|values)\\M'
|
|
45796
|
+
or (s.query ~* '^\\s*(select|with)\\M' and s.query !~* '\\minto\\M')
|
|
45797
|
+
then left(s.query, ${G003_QUERY_CHARS}) end order by s.max_ms desc nulls last))[1] as longest_query,
|
|
45798
|
+
(array_agg(s.since order by s.max_ms desc nulls last))[1] as longest_since,
|
|
45799
|
+
min(s.since) as stats_since
|
|
45800
|
+
from s join pg_roles as r on r.oid = s.userid
|
|
45801
|
+
group by r.rolname
|
|
45802
|
+
order by 3 desc nulls last
|
|
45803
|
+
limit ${G003_MAX_ROLES}
|
|
45804
|
+
`;
|
|
45805
|
+
var G003_ROUTINES_SQL = `
|
|
45806
|
+
select n.nspname as schema, p.proname as name, p.prokind as kind, pg_get_userbyid(p.proowner) as owner,
|
|
45807
|
+
b.src ~* '\\mcommit\\M' as commits,
|
|
45808
|
+
b.src ~* '\\m(query_canceled|57014)\\M' as catches_cancel,
|
|
45809
|
+
(select array_agg(c) from unnest(p.proconfig) as c
|
|
45810
|
+
where split_part(c, '=', 1) = any($1)) as config
|
|
45811
|
+
from pg_proc as p
|
|
45812
|
+
join pg_namespace as n on n.oid = p.pronamespace
|
|
45813
|
+
-- The code without its comments and \`on commit drop\`, which are not a commit.
|
|
45814
|
+
cross join lateral (select regexp_replace(regexp_replace(regexp_replace(p.prosrc, '/\\*.*?\\*/', '', 'g'),
|
|
45815
|
+
'--[^\\n]*', '', 'g'),
|
|
45816
|
+
'on\\s+commit\\s+\\w+(\\s+\\w+)?', '', 'gi') as src) as b
|
|
45817
|
+
where n.nspname not in ('pg_catalog', 'information_schema') and n.nspname !~ '^pg_(toast|temp)'
|
|
45818
|
+
and (p.prokind = 'p' or exists (select 1 from unnest(p.proconfig) as c
|
|
45819
|
+
where split_part(c, '=', 1) = any($1)))
|
|
45820
|
+
and not exists (select 1 from pg_depend as d
|
|
45821
|
+
where d.classid = 'pg_proc'::regclass and d.objid = p.oid and d.deptype = 'e')
|
|
45822
|
+
order by n.nspname, p.proname
|
|
45823
|
+
limit ${G003_MAX_ROUTINES}
|
|
45824
|
+
`;
|
|
45825
|
+
function g003Settings(config) {
|
|
45826
|
+
const out = {};
|
|
45827
|
+
for (const item of Array.isArray(config) ? config : []) {
|
|
45828
|
+
const text = String(item);
|
|
45829
|
+
const at = text.indexOf("=");
|
|
45830
|
+
const name = at < 0 ? text : text.slice(0, at);
|
|
45831
|
+
if (G003_TIMEOUT_SETTINGS.includes(name))
|
|
45832
|
+
out[name] = at < 0 ? "" : text.slice(at + 1);
|
|
45833
|
+
}
|
|
45834
|
+
return out;
|
|
45835
|
+
}
|
|
45836
|
+
async function g003ReadRoles(client) {
|
|
45837
|
+
const perDatabase = Object.create(null);
|
|
45838
|
+
for (const row of (await client.query(G003_ROLE_DATABASE_SQL)).rows) {
|
|
45839
|
+
const values = g003Settings(row.config);
|
|
45840
|
+
if (Object.keys(values).length) {
|
|
45841
|
+
(perDatabase[row.role] ??= Object.create(null))[row.database] = values;
|
|
45842
|
+
}
|
|
45843
|
+
}
|
|
45844
|
+
return (await client.query(G003_ROLES_SQL)).rows.map((row) => ({
|
|
45845
|
+
role: row.role,
|
|
45846
|
+
can_login: Boolean(row.can_login),
|
|
45847
|
+
superuser: Boolean(row.superuser),
|
|
45848
|
+
bypass_rls: Boolean(row.bypass_rls),
|
|
45849
|
+
member_of: row.member_of || [],
|
|
45850
|
+
settings: g003Settings(row.config),
|
|
45851
|
+
database_settings: perDatabase[row.role] || {}
|
|
45852
|
+
}));
|
|
45853
|
+
}
|
|
45854
|
+
async function g003ReadCalls(client) {
|
|
45855
|
+
const schema = (await client.query(G003_PGSS_SCHEMA_SQL)).rows[0]?.schema;
|
|
45856
|
+
if (!schema)
|
|
45857
|
+
throw new Error("pg_stat_statements is not installed");
|
|
45858
|
+
const quoted = `"${String(schema).replace(/"/g, '""')}"`;
|
|
45859
|
+
const calls = new Map;
|
|
45860
|
+
for (const row of (await client.query(g003CallsSql(quoted))).rows) {
|
|
45861
|
+
calls.set(row.role, {
|
|
45862
|
+
calls: parseInt(row.calls, 10) || 0,
|
|
45863
|
+
longest_call_ms: row.longest_ms === null ? null : Math.round(parseFloat(row.longest_ms) * 10) / 10,
|
|
45864
|
+
longest_call_queryid: row.longest_queryid,
|
|
45865
|
+
longest_call_query: row.longest_query,
|
|
45866
|
+
longest_call_since: row.longest_since,
|
|
45867
|
+
stats_since: row.stats_since
|
|
45868
|
+
});
|
|
45869
|
+
}
|
|
45870
|
+
return calls;
|
|
45871
|
+
}
|
|
45872
|
+
async function g003CatalogFacts(client) {
|
|
45873
|
+
const out = {};
|
|
45874
|
+
const fact = async (key, read) => {
|
|
45875
|
+
try {
|
|
45876
|
+
const value = await read();
|
|
45877
|
+
out[key] = value;
|
|
45878
|
+
return value;
|
|
45879
|
+
} catch (err) {
|
|
45880
|
+
out[`${key}_error`] = a005Error(err);
|
|
45881
|
+
return;
|
|
45882
|
+
}
|
|
45883
|
+
};
|
|
45884
|
+
await fact("read_as", async () => (await client.query("select current_user as role, current_database() as database")).rows[0]);
|
|
45885
|
+
await fact("server_settings", async () => {
|
|
45886
|
+
const server = {};
|
|
45887
|
+
for (const row of (await client.query(G003_SERVER_SQL, [G003_TIMEOUT_SETTINGS])).rows) {
|
|
45888
|
+
server[row.name] = { setting: row.setting, unit: row.unit, source: row.source };
|
|
45889
|
+
}
|
|
45890
|
+
return server;
|
|
45891
|
+
});
|
|
45892
|
+
await fact("database_settings", async () => {
|
|
45893
|
+
const values = {};
|
|
45894
|
+
for (const row of (await client.query(G003_DATABASE_SQL)).rows) {
|
|
45895
|
+
const stored = g003Settings(row.config);
|
|
45896
|
+
if (Object.keys(stored).length)
|
|
45897
|
+
values[row.database] = stored;
|
|
45898
|
+
}
|
|
45899
|
+
return values;
|
|
45900
|
+
});
|
|
45901
|
+
const roles = await fact("roles", () => g003ReadRoles(client));
|
|
45902
|
+
const calls = await fact("calls", () => g003ReadCalls(client));
|
|
45903
|
+
delete out.calls;
|
|
45904
|
+
if (roles && calls) {
|
|
45905
|
+
for (const role of roles)
|
|
45906
|
+
Object.assign(role, calls.get(role.role) || {});
|
|
45907
|
+
}
|
|
45908
|
+
if (roles && roles.length > G003_MAX_ROLES) {
|
|
45909
|
+
const useful = (role) => Object.keys(role.settings).length || Object.keys(role.database_settings).length || role.calls;
|
|
45910
|
+
out.roles_total = roles.length;
|
|
45911
|
+
out.roles = [...roles.filter(useful), ...roles.filter((role) => !useful(role))].slice(0, G003_MAX_ROLES);
|
|
45912
|
+
}
|
|
45913
|
+
await fact("routines", async () => (await client.query(G003_ROUTINES_SQL, [G003_TIMEOUT_SETTINGS])).rows.map((row) => ({
|
|
45914
|
+
schema: row.schema,
|
|
45915
|
+
name: row.name,
|
|
45916
|
+
kind: row.kind === "p" ? "procedure" : "function",
|
|
45917
|
+
owner: row.owner,
|
|
45918
|
+
commits: Boolean(row.commits),
|
|
45919
|
+
catches_cancel: Boolean(row.catches_cancel),
|
|
45920
|
+
settings: g003Settings(row.config)
|
|
45921
|
+
})));
|
|
45922
|
+
return out;
|
|
45923
|
+
}
|
|
45765
45924
|
async function generateG003(client, nodeName) {
|
|
45766
45925
|
const report = createBaseReport("G003", "Timeouts, locks, deadlocks", nodeName);
|
|
45767
45926
|
const postgresVersion = await getPostgresVersion(client);
|
|
@@ -45814,7 +45973,8 @@ async function generateG003(client, nodeName) {
|
|
|
45814
45973
|
data: {
|
|
45815
45974
|
settings: lockSettings,
|
|
45816
45975
|
deadlock_stats: deadlockStats,
|
|
45817
|
-
...deadlockError && { deadlock_stats_error: deadlockError }
|
|
45976
|
+
...deadlockError && { deadlock_stats_error: deadlockError },
|
|
45977
|
+
...await g003CatalogFacts(client)
|
|
45818
45978
|
},
|
|
45819
45979
|
postgres_version: postgresVersion
|
|
45820
45980
|
};
|
package/package.json
CHANGED
package/schemas/F004.schema.json
CHANGED
|
@@ -72,7 +72,47 @@
|
|
|
72
72
|
"last_vacuum_epoch": { "type": "number" },
|
|
73
73
|
"real_size_pretty": { "type": "string" },
|
|
74
74
|
"extra_size_pretty": { "type": "string" },
|
|
75
|
-
"bloat_size_pretty": { "type": "string" }
|
|
75
|
+
"bloat_size_pretty": { "type": "string" },
|
|
76
|
+
"n_live_tup": { "type": ["integer", "null"] },
|
|
77
|
+
"n_dead_tup": { "type": ["integer", "null"] },
|
|
78
|
+
"vacuum_threshold": { "type": ["integer", "null"] },
|
|
79
|
+
"autovacuum_runs_in_window": { "type": ["integer", "null"] },
|
|
80
|
+
"vacuum_runs_in_window": { "type": ["integer", "null"] },
|
|
81
|
+
"n_tup_ins_in_window": { "type": ["integer", "null"] },
|
|
82
|
+
"n_tup_upd_in_window": { "type": ["integer", "null"] },
|
|
83
|
+
"n_tup_del_in_window": { "type": ["integer", "null"] },
|
|
84
|
+
"n_tup_hot_upd_in_window": { "type": ["integer", "null"] },
|
|
85
|
+
"table_size_bytes": { "type": ["integer", "null"] },
|
|
86
|
+
"toast_size_bytes": { "type": ["integer", "null"] },
|
|
87
|
+
"table_size_min_in_window_bytes": { "type": ["integer", "null"] },
|
|
88
|
+
"table_size_max_in_window_bytes": { "type": ["integer", "null"] },
|
|
89
|
+
"bloat_size_min_in_window_bytes": { "type": ["integer", "null"] },
|
|
90
|
+
"bloat_size_max_in_window_bytes": { "type": ["integer", "null"] },
|
|
91
|
+
"seconds_since_last_vacuum": { "type": ["integer", "null"] },
|
|
92
|
+
"vacuum_recorded": { "type": ["boolean", "null"] },
|
|
93
|
+
"autovacuum_disabled": { "type": ["boolean", "null"] }
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"history": {
|
|
97
|
+
"type": "object",
|
|
98
|
+
"additionalProperties": false,
|
|
99
|
+
"required": ["daily", "first_reading_at"],
|
|
100
|
+
"properties": {
|
|
101
|
+
"daily": {
|
|
102
|
+
"type": "array",
|
|
103
|
+
"items": {
|
|
104
|
+
"type": "object",
|
|
105
|
+
"additionalProperties": false,
|
|
106
|
+
"required": ["days_ago", "at", "total_bloat_size_bytes"],
|
|
107
|
+
"properties": {
|
|
108
|
+
"days_ago": { "type": "integer" },
|
|
109
|
+
"at": { "type": ["string", "null"] },
|
|
110
|
+
"total_bloat_size_bytes": { "type": "integer" }
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"first_reading_at": { "type": ["string", "null"] },
|
|
115
|
+
"window_seconds": { "type": "integer" }
|
|
76
116
|
}
|
|
77
117
|
},
|
|
78
118
|
"dbEntry": {
|
|
@@ -93,7 +133,17 @@
|
|
|
93
133
|
"total_bloat_size_bytes": { "type": "number" },
|
|
94
134
|
"total_bloat_size_pretty": { "type": "string" },
|
|
95
135
|
"database_size_bytes": { "type": "number" },
|
|
96
|
-
"database_size_pretty": { "type": "string" }
|
|
136
|
+
"database_size_pretty": { "type": "string" },
|
|
137
|
+
"history": { "$ref": "#/$defs/history" },
|
|
138
|
+
"autovacuum_settings": {
|
|
139
|
+
"type": "object",
|
|
140
|
+
"additionalProperties": false,
|
|
141
|
+
"required": ["autovacuum_vacuum_threshold", "autovacuum_vacuum_scale_factor"],
|
|
142
|
+
"properties": {
|
|
143
|
+
"autovacuum_vacuum_threshold": { "type": "number" },
|
|
144
|
+
"autovacuum_vacuum_scale_factor": { "type": "number" }
|
|
145
|
+
}
|
|
146
|
+
}
|
|
97
147
|
}
|
|
98
148
|
},
|
|
99
149
|
"status": {
|
package/schemas/G001.schema.json
CHANGED
|
@@ -117,7 +117,71 @@
|
|
|
117
117
|
"type": "object",
|
|
118
118
|
"additionalProperties": { "$ref": "#/$defs/setting" }
|
|
119
119
|
},
|
|
120
|
-
"analysis": { "$ref": "#/$defs/analysis" }
|
|
120
|
+
"analysis": { "$ref": "#/$defs/analysis" },
|
|
121
|
+
"activity": { "$ref": "#/$defs/activity" }
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
"peak": {
|
|
125
|
+
"type": "object",
|
|
126
|
+
"additionalProperties": false,
|
|
127
|
+
"required": ["peak"],
|
|
128
|
+
"properties": {
|
|
129
|
+
"peak": { "type": "integer" },
|
|
130
|
+
"peak_at": { "type": "string" },
|
|
131
|
+
"mean": { "type": "number" }
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
"activity": {
|
|
135
|
+
"type": "object",
|
|
136
|
+
"additionalProperties": false,
|
|
137
|
+
"properties": {
|
|
138
|
+
"window": {
|
|
139
|
+
"type": "object",
|
|
140
|
+
"additionalProperties": false,
|
|
141
|
+
"required": ["start", "end", "seconds"],
|
|
142
|
+
"properties": {
|
|
143
|
+
"start": { "type": "string" },
|
|
144
|
+
"end": { "type": "string" },
|
|
145
|
+
"seconds": { "type": "integer" },
|
|
146
|
+
"samples": { "type": "integer" },
|
|
147
|
+
"sample_seconds": { "type": ["integer", "null"] }
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
"databases": { "type": "array", "items": { "type": "string" } },
|
|
151
|
+
"connections": { "$ref": "#/$defs/peak" },
|
|
152
|
+
"active_statements": { "$ref": "#/$defs/peak" },
|
|
153
|
+
"applications": {
|
|
154
|
+
"type": "array",
|
|
155
|
+
"items": {
|
|
156
|
+
"type": "object",
|
|
157
|
+
"additionalProperties": false,
|
|
158
|
+
"required": ["application", "peak"],
|
|
159
|
+
"properties": { "application": { "type": "string" }, "peak": { "type": "integer" } }
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"server": {
|
|
163
|
+
"type": "object",
|
|
164
|
+
"additionalProperties": false,
|
|
165
|
+
"properties": {
|
|
166
|
+
"last_start": { "type": "string" },
|
|
167
|
+
"starts_in_window": { "type": "integer" },
|
|
168
|
+
"stats_resets": { "type": "integer" },
|
|
169
|
+
"sessions_fatal": { "type": "integer" },
|
|
170
|
+
"sessions_killed": { "type": "integer" },
|
|
171
|
+
"sessions_abandoned": { "type": "integer" }
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
"host_memory": {
|
|
175
|
+
"type": "object",
|
|
176
|
+
"additionalProperties": false,
|
|
177
|
+
"required": ["total_bytes", "available_min_pct"],
|
|
178
|
+
"properties": {
|
|
179
|
+
"total_bytes": { "type": "integer" },
|
|
180
|
+
"available_min_pct": { "type": "number" },
|
|
181
|
+
"available_min_at": { "type": "string" },
|
|
182
|
+
"available_p5_pct": { "type": "number" }
|
|
183
|
+
}
|
|
184
|
+
}
|
|
121
185
|
}
|
|
122
186
|
},
|
|
123
187
|
"nodeResult": {
|
|
@@ -131,5 +195,3 @@
|
|
|
131
195
|
}
|
|
132
196
|
}
|
|
133
197
|
}
|
|
134
|
-
|
|
135
|
-
|
package/schemas/G003.schema.json
CHANGED
|
@@ -64,6 +64,104 @@
|
|
|
64
64
|
"stats_reset": { "type": ["string", "null"] }
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
|
+
"timeoutValues": {
|
|
68
|
+
"type": "object",
|
|
69
|
+
"additionalProperties": { "type": "string" }
|
|
70
|
+
},
|
|
71
|
+
"role": {
|
|
72
|
+
"type": "object",
|
|
73
|
+
"additionalProperties": false,
|
|
74
|
+
"required": ["role", "can_login", "superuser", "bypass_rls", "member_of", "settings", "database_settings"],
|
|
75
|
+
"properties": {
|
|
76
|
+
"role": { "type": "string" },
|
|
77
|
+
"can_login": { "type": "boolean" },
|
|
78
|
+
"superuser": { "type": "boolean" },
|
|
79
|
+
"bypass_rls": { "type": "boolean" },
|
|
80
|
+
"member_of": { "type": "array", "items": { "type": "string" } },
|
|
81
|
+
"settings": { "$ref": "#/$defs/timeoutValues" },
|
|
82
|
+
"database_settings": { "type": "object", "additionalProperties": { "$ref": "#/$defs/timeoutValues" } },
|
|
83
|
+
"calls": { "type": "integer" },
|
|
84
|
+
"longest_call_ms": { "type": ["number", "null"] },
|
|
85
|
+
"longest_call_queryid": { "type": ["string", "null"] },
|
|
86
|
+
"longest_call_query": { "type": ["string", "null"] },
|
|
87
|
+
"longest_call_since": { "type": ["string", "null"] },
|
|
88
|
+
"stats_since": { "type": ["string", "null"] }
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"routine": {
|
|
92
|
+
"type": "object",
|
|
93
|
+
"additionalProperties": false,
|
|
94
|
+
"required": ["schema", "name", "kind", "owner", "commits", "catches_cancel", "settings"],
|
|
95
|
+
"properties": {
|
|
96
|
+
"schema": { "type": "string" },
|
|
97
|
+
"name": { "type": "string" },
|
|
98
|
+
"kind": { "enum": ["procedure", "function"] },
|
|
99
|
+
"owner": { "type": "string" },
|
|
100
|
+
"commits": { "type": "boolean" },
|
|
101
|
+
"catches_cancel": { "type": "boolean" },
|
|
102
|
+
"settings": { "$ref": "#/$defs/timeoutValues" }
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"deadlockWindow": {
|
|
106
|
+
"type": "object",
|
|
107
|
+
"additionalProperties": false,
|
|
108
|
+
"required": ["start", "end", "days", "step_seconds", "deadlocks", "days_with_deadlocks", "per_day", "by_database"],
|
|
109
|
+
"properties": {
|
|
110
|
+
"start": { "type": "string" },
|
|
111
|
+
"end": { "type": "string" },
|
|
112
|
+
"days": { "type": "number" },
|
|
113
|
+
"step_seconds": { "type": "integer" },
|
|
114
|
+
"deadlocks": { "type": "integer" },
|
|
115
|
+
"days_with_deadlocks": { "type": "integer" },
|
|
116
|
+
"per_day": {
|
|
117
|
+
"type": "array",
|
|
118
|
+
"items": {
|
|
119
|
+
"type": "object",
|
|
120
|
+
"additionalProperties": false,
|
|
121
|
+
"required": ["date", "deadlocks"],
|
|
122
|
+
"properties": { "date": { "type": "string" }, "deadlocks": { "type": "integer" } }
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"by_database": { "type": "object", "additionalProperties": { "type": "integer" } },
|
|
126
|
+
"peak_hour_utc": { "type": "integer" },
|
|
127
|
+
"peak_hour_deadlocks": { "type": "integer" },
|
|
128
|
+
"worst_step_end": { "type": "string" },
|
|
129
|
+
"worst_step_deadlocks": { "type": "integer" }
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"lockWaits": {
|
|
133
|
+
"type": "object",
|
|
134
|
+
"additionalProperties": false,
|
|
135
|
+
"required": ["start", "end", "days", "pairs_total", "session_pairs_total", "pairs"],
|
|
136
|
+
"properties": {
|
|
137
|
+
"start": { "type": ["string", "null"] },
|
|
138
|
+
"end": { "type": ["string", "null"] },
|
|
139
|
+
"days": { "type": ["number", "null"] },
|
|
140
|
+
"pairs_total": { "type": "integer" },
|
|
141
|
+
"session_pairs_total": { "type": "integer" },
|
|
142
|
+
"pairs": {
|
|
143
|
+
"type": "array",
|
|
144
|
+
"items": {
|
|
145
|
+
"type": "object",
|
|
146
|
+
"additionalProperties": false,
|
|
147
|
+
"required": ["blocked_query_id", "blocked_user", "blocked_table", "blocker_query_id", "blocker_user", "blocker_table", "sessions", "longest_blocked_statement_age_ms", "longest_at"],
|
|
148
|
+
"properties": {
|
|
149
|
+
"blocked_query_id": { "type": "string" },
|
|
150
|
+
"blocked_user": { "type": "string" },
|
|
151
|
+
"blocked_table": { "type": "string" },
|
|
152
|
+
"blocker_query_id": { "type": "string" },
|
|
153
|
+
"blocker_user": { "type": "string" },
|
|
154
|
+
"blocker_table": { "type": "string" },
|
|
155
|
+
"sessions": { "type": "integer" },
|
|
156
|
+
"longest_blocked_statement_age_ms": { "type": "integer" },
|
|
157
|
+
"longest_at": { "type": ["string", "null"] },
|
|
158
|
+
"blocked_query": { "type": ["string", "null"] },
|
|
159
|
+
"blocker_query": { "type": ["string", "null"] }
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
},
|
|
67
165
|
"data": {
|
|
68
166
|
"type": "object",
|
|
69
167
|
"additionalProperties": false,
|
|
@@ -74,7 +172,36 @@
|
|
|
74
172
|
"additionalProperties": { "$ref": "#/$defs/setting" }
|
|
75
173
|
},
|
|
76
174
|
"deadlock_stats": { "$ref": "#/$defs/deadlockStats" },
|
|
77
|
-
"deadlock_stats_error": { "type": "string" }
|
|
175
|
+
"deadlock_stats_error": { "type": "string" },
|
|
176
|
+
"deadlock_window": { "$ref": "#/$defs/deadlockWindow" },
|
|
177
|
+
"deadlock_window_error": { "type": "string" },
|
|
178
|
+
"lock_waits": { "$ref": "#/$defs/lockWaits" },
|
|
179
|
+
"lock_waits_error": { "type": "string" },
|
|
180
|
+
"read_as": {
|
|
181
|
+
"type": "object",
|
|
182
|
+
"additionalProperties": false,
|
|
183
|
+
"required": ["role", "database"],
|
|
184
|
+
"properties": { "role": { "type": "string" }, "database": { "type": "string" } }
|
|
185
|
+
},
|
|
186
|
+
"read_as_error": { "type": "string" },
|
|
187
|
+
"server_settings": {
|
|
188
|
+
"type": "object",
|
|
189
|
+
"additionalProperties": {
|
|
190
|
+
"type": "object",
|
|
191
|
+
"additionalProperties": false,
|
|
192
|
+
"required": ["setting", "unit", "source"],
|
|
193
|
+
"properties": { "setting": { "type": "string" }, "unit": { "type": "string" }, "source": { "type": "string" } }
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
"server_settings_error": { "type": "string" },
|
|
197
|
+
"database_settings": { "type": "object", "additionalProperties": { "$ref": "#/$defs/timeoutValues" } },
|
|
198
|
+
"database_settings_error": { "type": "string" },
|
|
199
|
+
"roles": { "type": "array", "items": { "$ref": "#/$defs/role" } },
|
|
200
|
+
"roles_total": { "type": "integer" },
|
|
201
|
+
"roles_error": { "type": "string" },
|
|
202
|
+
"calls_error": { "type": "string" },
|
|
203
|
+
"routines": { "type": "array", "items": { "$ref": "#/$defs/routine" } },
|
|
204
|
+
"routines_error": { "type": "string" }
|
|
78
205
|
}
|
|
79
206
|
},
|
|
80
207
|
"nodeResult": {
|
package/schemas/H001.schema.json
CHANGED
|
@@ -101,7 +101,21 @@
|
|
|
101
101
|
"valid_duplicate_definition": {
|
|
102
102
|
"type": ["string", "null"],
|
|
103
103
|
"description": "Full CREATE INDEX statement of the valid duplicate index from pg_get_indexdef()"
|
|
104
|
-
}
|
|
104
|
+
},
|
|
105
|
+
"is_ready": {
|
|
106
|
+
"type": "boolean",
|
|
107
|
+
"description": "pg_index.indisready: false = writes do not maintain the index; absent when the box does not collect it"
|
|
108
|
+
},
|
|
109
|
+
"build_in_progress": {
|
|
110
|
+
"type": "boolean",
|
|
111
|
+
"description": "A CREATE INDEX for it is running (pg_stat_progress_create_index): not a leftover yet"
|
|
112
|
+
},
|
|
113
|
+
"first_seen_epoch": { "type": "number", "description": "First monitored reading in the lookback that listed it" },
|
|
114
|
+
"first_seen_time": { "type": "string" },
|
|
115
|
+
"last_seen_epoch": { "type": "number" },
|
|
116
|
+
"last_seen_time": { "type": "string" },
|
|
117
|
+
"listed_hours": { "type": "integer", "description": "Hourly steps from first_seen that listed it" },
|
|
118
|
+
"reading_hours": { "type": "integer", "description": "Hourly steps from first_seen with a database-size reading" }
|
|
105
119
|
}
|
|
106
120
|
},
|
|
107
121
|
"dbEntry": {
|
|
@@ -121,7 +135,32 @@
|
|
|
121
135
|
"total_size_bytes": { "type": "number" },
|
|
122
136
|
"total_size_pretty": { "type": "string" },
|
|
123
137
|
"database_size_bytes": { "type": "number" },
|
|
124
|
-
"database_size_pretty": { "type": "string" }
|
|
138
|
+
"database_size_pretty": { "type": "string" },
|
|
139
|
+
"not_valid_constraints": {
|
|
140
|
+
"type": "object",
|
|
141
|
+
"additionalProperties": false,
|
|
142
|
+
"required": ["total_count", "constraints"],
|
|
143
|
+
"description": "Constraints added NOT VALID and never validated; absent when the box does not collect them",
|
|
144
|
+
"properties": {
|
|
145
|
+
"total_count": { "type": "integer" },
|
|
146
|
+
"constraints": { "type": "array", "items": { "$ref": "#/$defs/notValidConstraint" } }
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
"monitoring_start_epoch": { "type": "number", "description": "First database-size reading in the lookback" },
|
|
150
|
+
"monitoring_start_time": { "type": "string" }
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"notValidConstraint": {
|
|
154
|
+
"type": "object",
|
|
155
|
+
"additionalProperties": false,
|
|
156
|
+
"required": ["schema_name", "table_name", "constraint_name", "constraint_type", "constraint_definition", "is_partition_copy"],
|
|
157
|
+
"properties": {
|
|
158
|
+
"schema_name": { "type": "string" },
|
|
159
|
+
"table_name": { "type": "string" },
|
|
160
|
+
"constraint_name": { "type": "string" },
|
|
161
|
+
"constraint_type": { "type": "string", "description": "c = CHECK, f = FOREIGN KEY" },
|
|
162
|
+
"constraint_definition": { "type": "string" },
|
|
163
|
+
"is_partition_copy": { "type": "boolean", "description": "A partition's copy of a parent's constraint" }
|
|
125
164
|
}
|
|
126
165
|
},
|
|
127
166
|
"data": {
|