pg_reports 0.3.1 → 0.4.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +36 -0
- data/app/controllers/pg_reports/dashboard_controller.rb +59 -4
- data/app/views/layouts/pg_reports/application.html.erb +1 -1
- data/app/views/pg_reports/dashboard/_show_modals.html.erb +8 -1
- data/app/views/pg_reports/dashboard/_show_scripts.html.erb +56 -18
- data/app/views/pg_reports/dashboard/_show_styles.html.erb +122 -1
- data/app/views/pg_reports/dashboard/show.html.erb +89 -47
- data/config/locales/en.yml +13 -0
- data/config/locales/ru.yml +13 -0
- data/config/locales/uk.yml +13 -0
- data/lib/pg_reports/dashboard/reports_registry.rb +14 -0
- data/lib/pg_reports/definitions/connections/active_connections.yml +23 -0
- data/lib/pg_reports/definitions/connections/blocking_queries.yml +20 -0
- data/lib/pg_reports/definitions/connections/connection_stats.yml +18 -0
- data/lib/pg_reports/definitions/connections/idle_connections.yml +21 -0
- data/lib/pg_reports/definitions/connections/locks.yml +22 -0
- data/lib/pg_reports/definitions/connections/long_running_queries.yml +43 -0
- data/lib/pg_reports/definitions/indexes/bloated_indexes.yml +43 -0
- data/lib/pg_reports/definitions/indexes/duplicate_indexes.yml +19 -0
- data/lib/pg_reports/definitions/indexes/index_sizes.yml +29 -0
- data/lib/pg_reports/definitions/indexes/index_usage.yml +27 -0
- data/lib/pg_reports/definitions/indexes/invalid_indexes.yml +19 -0
- data/lib/pg_reports/definitions/indexes/missing_indexes.yml +27 -0
- data/lib/pg_reports/definitions/indexes/unused_indexes.yml +41 -0
- data/lib/pg_reports/definitions/queries/all_queries.yml +35 -0
- data/lib/pg_reports/definitions/queries/expensive_queries.yml +43 -0
- data/lib/pg_reports/definitions/queries/heavy_queries.yml +49 -0
- data/lib/pg_reports/definitions/queries/low_cache_hit_queries.yml +47 -0
- data/lib/pg_reports/definitions/queries/missing_index_queries.yml +31 -0
- data/lib/pg_reports/definitions/queries/slow_queries.yml +48 -0
- data/lib/pg_reports/definitions/system/activity_overview.yml +17 -0
- data/lib/pg_reports/definitions/system/cache_stats.yml +18 -0
- data/lib/pg_reports/definitions/system/database_sizes.yml +18 -0
- data/lib/pg_reports/definitions/system/extensions.yml +19 -0
- data/lib/pg_reports/definitions/system/settings.yml +20 -0
- data/lib/pg_reports/definitions/tables/bloated_tables.yml +43 -0
- data/lib/pg_reports/definitions/tables/cache_hit_ratios.yml +26 -0
- data/lib/pg_reports/definitions/tables/recently_modified.yml +27 -0
- data/lib/pg_reports/definitions/tables/row_counts.yml +29 -0
- data/lib/pg_reports/definitions/tables/seq_scans.yml +31 -0
- data/lib/pg_reports/definitions/tables/table_sizes.yml +31 -0
- data/lib/pg_reports/definitions/tables/vacuum_needed.yml +39 -0
- data/lib/pg_reports/filter.rb +58 -0
- data/lib/pg_reports/module_generator.rb +44 -0
- data/lib/pg_reports/modules/connections.rb +8 -73
- data/lib/pg_reports/modules/indexes.rb +9 -94
- data/lib/pg_reports/modules/queries.rb +9 -100
- data/lib/pg_reports/modules/schema_analysis.rb +156 -0
- data/lib/pg_reports/modules/system.rb +7 -59
- data/lib/pg_reports/modules/tables.rb +9 -96
- data/lib/pg_reports/report_definition.rb +161 -0
- data/lib/pg_reports/report_loader.rb +38 -0
- data/lib/pg_reports/sql/schema_analysis/unique_indexes.sql +35 -0
- data/lib/pg_reports/version.rb +1 -1
- data/lib/pg_reports.rb +24 -0
- metadata +38 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
-- Unique indexes: all unique indexes in the database
|
|
2
|
+
-- Used for validation consistency analysis
|
|
3
|
+
|
|
4
|
+
SELECT
|
|
5
|
+
n.nspname AS schema_name,
|
|
6
|
+
t.relname AS table_name,
|
|
7
|
+
i.relname AS index_name,
|
|
8
|
+
array_agg(a.attname ORDER BY array_position(ix.indkey, a.attnum)) AS column_names,
|
|
9
|
+
pg_get_indexdef(i.oid) AS index_definition,
|
|
10
|
+
CASE
|
|
11
|
+
WHEN ix.indisprimary THEN 'primary_key'
|
|
12
|
+
WHEN ix.indisunique THEN 'unique'
|
|
13
|
+
ELSE 'regular'
|
|
14
|
+
END AS index_type
|
|
15
|
+
FROM
|
|
16
|
+
pg_index ix
|
|
17
|
+
JOIN pg_class i ON i.oid = ix.indexrelid
|
|
18
|
+
JOIN pg_class t ON t.oid = ix.indrelid
|
|
19
|
+
JOIN pg_namespace n ON n.oid = t.relnamespace
|
|
20
|
+
JOIN pg_attribute a ON a.attrelid = t.oid AND a.attnum = ANY(ix.indkey)
|
|
21
|
+
WHERE
|
|
22
|
+
n.nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast')
|
|
23
|
+
AND (ix.indisunique = true OR ix.indisprimary = true)
|
|
24
|
+
AND t.relkind = 'r'
|
|
25
|
+
GROUP BY
|
|
26
|
+
n.nspname,
|
|
27
|
+
t.relname,
|
|
28
|
+
i.relname,
|
|
29
|
+
i.oid,
|
|
30
|
+
ix.indisprimary,
|
|
31
|
+
ix.indisunique
|
|
32
|
+
ORDER BY
|
|
33
|
+
n.nspname,
|
|
34
|
+
t.relname,
|
|
35
|
+
i.relname;
|
data/lib/pg_reports/version.rb
CHANGED
data/lib/pg_reports.rb
CHANGED
|
@@ -13,12 +13,19 @@ require_relative "pg_reports/report"
|
|
|
13
13
|
require_relative "pg_reports/telegram_sender"
|
|
14
14
|
require_relative "pg_reports/annotation_parser"
|
|
15
15
|
|
|
16
|
+
# YAML-based report system
|
|
17
|
+
require_relative "pg_reports/filter"
|
|
18
|
+
require_relative "pg_reports/report_definition"
|
|
19
|
+
require_relative "pg_reports/report_loader"
|
|
20
|
+
require_relative "pg_reports/module_generator"
|
|
21
|
+
|
|
16
22
|
# Modules
|
|
17
23
|
require_relative "pg_reports/modules/queries"
|
|
18
24
|
require_relative "pg_reports/modules/indexes"
|
|
19
25
|
require_relative "pg_reports/modules/tables"
|
|
20
26
|
require_relative "pg_reports/modules/connections"
|
|
21
27
|
require_relative "pg_reports/modules/system"
|
|
28
|
+
require_relative "pg_reports/modules/schema_analysis"
|
|
22
29
|
|
|
23
30
|
# Dashboard
|
|
24
31
|
require_relative "pg_reports/dashboard/reports_registry"
|
|
@@ -56,6 +63,10 @@ module PgReports
|
|
|
56
63
|
:enable_pg_stat_statements!,
|
|
57
64
|
to: Modules::System
|
|
58
65
|
|
|
66
|
+
# Schema analysis methods
|
|
67
|
+
delegate :missing_validations,
|
|
68
|
+
to: Modules::SchemaAnalysis
|
|
69
|
+
|
|
59
70
|
# Generate a comprehensive database health report
|
|
60
71
|
# @return [Report] Combined health report
|
|
61
72
|
def health_report
|
|
@@ -110,5 +121,18 @@ module PgReports
|
|
|
110
121
|
def system
|
|
111
122
|
Modules::System
|
|
112
123
|
end
|
|
124
|
+
|
|
125
|
+
def schema_analysis
|
|
126
|
+
Modules::SchemaAnalysis
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Reload YAML report definitions and regenerate module methods
|
|
130
|
+
def reload_definitions!
|
|
131
|
+
ReportLoader.reload!
|
|
132
|
+
ModuleGenerator.generate!
|
|
133
|
+
end
|
|
113
134
|
end
|
|
114
135
|
end
|
|
136
|
+
|
|
137
|
+
# Generate YAML-based methods on load
|
|
138
|
+
PgReports::ModuleGenerator.generate!
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pg_reports
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Eldar Avatov
|
|
@@ -121,15 +121,51 @@ files:
|
|
|
121
121
|
- lib/pg_reports/annotation_parser.rb
|
|
122
122
|
- lib/pg_reports/configuration.rb
|
|
123
123
|
- lib/pg_reports/dashboard/reports_registry.rb
|
|
124
|
+
- lib/pg_reports/definitions/connections/active_connections.yml
|
|
125
|
+
- lib/pg_reports/definitions/connections/blocking_queries.yml
|
|
126
|
+
- lib/pg_reports/definitions/connections/connection_stats.yml
|
|
127
|
+
- lib/pg_reports/definitions/connections/idle_connections.yml
|
|
128
|
+
- lib/pg_reports/definitions/connections/locks.yml
|
|
129
|
+
- lib/pg_reports/definitions/connections/long_running_queries.yml
|
|
130
|
+
- lib/pg_reports/definitions/indexes/bloated_indexes.yml
|
|
131
|
+
- lib/pg_reports/definitions/indexes/duplicate_indexes.yml
|
|
132
|
+
- lib/pg_reports/definitions/indexes/index_sizes.yml
|
|
133
|
+
- lib/pg_reports/definitions/indexes/index_usage.yml
|
|
134
|
+
- lib/pg_reports/definitions/indexes/invalid_indexes.yml
|
|
135
|
+
- lib/pg_reports/definitions/indexes/missing_indexes.yml
|
|
136
|
+
- lib/pg_reports/definitions/indexes/unused_indexes.yml
|
|
137
|
+
- lib/pg_reports/definitions/queries/all_queries.yml
|
|
138
|
+
- lib/pg_reports/definitions/queries/expensive_queries.yml
|
|
139
|
+
- lib/pg_reports/definitions/queries/heavy_queries.yml
|
|
140
|
+
- lib/pg_reports/definitions/queries/low_cache_hit_queries.yml
|
|
141
|
+
- lib/pg_reports/definitions/queries/missing_index_queries.yml
|
|
142
|
+
- lib/pg_reports/definitions/queries/slow_queries.yml
|
|
143
|
+
- lib/pg_reports/definitions/system/activity_overview.yml
|
|
144
|
+
- lib/pg_reports/definitions/system/cache_stats.yml
|
|
145
|
+
- lib/pg_reports/definitions/system/database_sizes.yml
|
|
146
|
+
- lib/pg_reports/definitions/system/extensions.yml
|
|
147
|
+
- lib/pg_reports/definitions/system/settings.yml
|
|
148
|
+
- lib/pg_reports/definitions/tables/bloated_tables.yml
|
|
149
|
+
- lib/pg_reports/definitions/tables/cache_hit_ratios.yml
|
|
150
|
+
- lib/pg_reports/definitions/tables/recently_modified.yml
|
|
151
|
+
- lib/pg_reports/definitions/tables/row_counts.yml
|
|
152
|
+
- lib/pg_reports/definitions/tables/seq_scans.yml
|
|
153
|
+
- lib/pg_reports/definitions/tables/table_sizes.yml
|
|
154
|
+
- lib/pg_reports/definitions/tables/vacuum_needed.yml
|
|
124
155
|
- lib/pg_reports/engine.rb
|
|
125
156
|
- lib/pg_reports/error.rb
|
|
126
157
|
- lib/pg_reports/executor.rb
|
|
158
|
+
- lib/pg_reports/filter.rb
|
|
159
|
+
- lib/pg_reports/module_generator.rb
|
|
127
160
|
- lib/pg_reports/modules/connections.rb
|
|
128
161
|
- lib/pg_reports/modules/indexes.rb
|
|
129
162
|
- lib/pg_reports/modules/queries.rb
|
|
163
|
+
- lib/pg_reports/modules/schema_analysis.rb
|
|
130
164
|
- lib/pg_reports/modules/system.rb
|
|
131
165
|
- lib/pg_reports/modules/tables.rb
|
|
132
166
|
- lib/pg_reports/report.rb
|
|
167
|
+
- lib/pg_reports/report_definition.rb
|
|
168
|
+
- lib/pg_reports/report_loader.rb
|
|
133
169
|
- lib/pg_reports/sql/connections/active_connections.sql
|
|
134
170
|
- lib/pg_reports/sql/connections/blocking_queries.sql
|
|
135
171
|
- lib/pg_reports/sql/connections/connection_stats.sql
|
|
@@ -149,6 +185,7 @@ files:
|
|
|
149
185
|
- lib/pg_reports/sql/queries/low_cache_hit_queries.sql
|
|
150
186
|
- lib/pg_reports/sql/queries/missing_index_queries.sql
|
|
151
187
|
- lib/pg_reports/sql/queries/slow_queries.sql
|
|
188
|
+
- lib/pg_reports/sql/schema_analysis/unique_indexes.sql
|
|
152
189
|
- lib/pg_reports/sql/system/activity_overview.sql
|
|
153
190
|
- lib/pg_reports/sql/system/cache_stats.sql
|
|
154
191
|
- lib/pg_reports/sql/system/database_sizes.sql
|