ruby-pg-extras 5.6.18 → 5.8.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/README.md +57 -9
- data/lib/ruby-pg-extras.rb +12 -1
- data/lib/ruby_pg_extras/diagnose_data.rb +120 -0
- data/lib/ruby_pg_extras/index_info.rb +31 -1
- data/lib/ruby_pg_extras/index_info_print.rb +13 -0
- data/lib/ruby_pg_extras/missing_fk_indexes.rb +45 -1
- data/lib/ruby_pg_extras/queries/indexes.sql +76 -6
- data/lib/ruby_pg_extras/queries/update_stats.sql +71 -0
- data/lib/ruby_pg_extras/queries/update_stats_legacy.sql +46 -0
- data/lib/ruby_pg_extras/version.rb +1 -1
- data/spec/diagnose_data_spec.rb +252 -0
- data/spec/index_info_spec.rb +111 -2
- data/spec/missing_fk_indexes_spec.rb +113 -5
- data/spec/smoke_spec.rb +61 -0
- data/spec/spec_helper.rb +87 -0
- metadata +4 -2
data/spec/spec_helper.rb
CHANGED
|
@@ -26,7 +26,17 @@ DROP TABLE IF EXISTS categories;
|
|
|
26
26
|
DROP TABLE IF EXISTS customers;
|
|
27
27
|
DROP TABLE IF EXISTS events;
|
|
28
28
|
DROP TABLE IF EXISTS subjects;
|
|
29
|
+
DROP TABLE IF EXISTS collated_indexed_codes;
|
|
30
|
+
DROP TABLE IF EXISTS opclass_indexed_codes;
|
|
31
|
+
DROP TABLE IF EXISTS included_indexed_posts;
|
|
32
|
+
DROP TABLE IF EXISTS sorted_indexed_posts;
|
|
33
|
+
DROP TABLE IF EXISTS null_partial_indexed_posts;
|
|
34
|
+
DROP TABLE IF EXISTS not_null_partial_indexed_posts;
|
|
35
|
+
DROP TABLE IF EXISTS partial_indexed_posts;
|
|
36
|
+
DROP TABLE IF EXISTS expression_not_null_partial_indexed_posts;
|
|
37
|
+
DROP TABLE IF EXISTS expression_indexed_posts;
|
|
29
38
|
DROP TABLE IF EXISTS posts;
|
|
39
|
+
DROP TABLE IF EXISTS codes;
|
|
30
40
|
DROP TABLE IF EXISTS users;
|
|
31
41
|
DROP TABLE IF EXISTS topics;
|
|
32
42
|
DROP TABLE IF EXISTS companies;
|
|
@@ -49,6 +59,10 @@ CREATE TABLE topics (
|
|
|
49
59
|
title VARCHAR(255)
|
|
50
60
|
);
|
|
51
61
|
|
|
62
|
+
CREATE TABLE codes (
|
|
63
|
+
code TEXT PRIMARY KEY
|
|
64
|
+
);
|
|
65
|
+
|
|
52
66
|
CREATE TABLE posts (
|
|
53
67
|
id SERIAL PRIMARY KEY,
|
|
54
68
|
user_id INTEGER NOT NULL,
|
|
@@ -60,6 +74,60 @@ CREATE TABLE posts (
|
|
|
60
74
|
CONSTRAINT fk_posts_topic FOREIGN KEY (topic_id) REFERENCES topics(id) ON DELETE CASCADE
|
|
61
75
|
);
|
|
62
76
|
|
|
77
|
+
CREATE TABLE expression_indexed_posts (
|
|
78
|
+
id SERIAL PRIMARY KEY,
|
|
79
|
+
topic_id INTEGER,
|
|
80
|
+
CONSTRAINT fk_expression_indexed_posts_topic FOREIGN KEY (topic_id) REFERENCES topics(id)
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
CREATE TABLE expression_not_null_partial_indexed_posts (
|
|
84
|
+
id SERIAL PRIMARY KEY,
|
|
85
|
+
topic_id INTEGER,
|
|
86
|
+
CONSTRAINT fk_expression_not_null_partial_indexed_posts_topic FOREIGN KEY (topic_id) REFERENCES topics(id)
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
CREATE TABLE partial_indexed_posts (
|
|
90
|
+
id SERIAL PRIMARY KEY,
|
|
91
|
+
topic_id INTEGER,
|
|
92
|
+
CONSTRAINT fk_partial_indexed_posts_topic FOREIGN KEY (topic_id) REFERENCES topics(id)
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
CREATE TABLE sorted_indexed_posts (
|
|
96
|
+
id SERIAL PRIMARY KEY,
|
|
97
|
+
topic_id INTEGER,
|
|
98
|
+
CONSTRAINT fk_sorted_indexed_posts_topic FOREIGN KEY (topic_id) REFERENCES topics(id)
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
CREATE TABLE not_null_partial_indexed_posts (
|
|
102
|
+
id SERIAL PRIMARY KEY,
|
|
103
|
+
topic_id INTEGER,
|
|
104
|
+
CONSTRAINT fk_not_null_partial_indexed_posts_topic FOREIGN KEY (topic_id) REFERENCES topics(id)
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
CREATE TABLE null_partial_indexed_posts (
|
|
108
|
+
id SERIAL PRIMARY KEY,
|
|
109
|
+
topic_id INTEGER,
|
|
110
|
+
CONSTRAINT fk_null_partial_indexed_posts_topic FOREIGN KEY (topic_id) REFERENCES topics(id)
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
CREATE TABLE included_indexed_posts (
|
|
114
|
+
id SERIAL PRIMARY KEY,
|
|
115
|
+
topic_id INTEGER,
|
|
116
|
+
CONSTRAINT fk_included_indexed_posts_topic FOREIGN KEY (topic_id) REFERENCES topics(id)
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
CREATE TABLE opclass_indexed_codes (
|
|
120
|
+
id SERIAL PRIMARY KEY,
|
|
121
|
+
code TEXT,
|
|
122
|
+
CONSTRAINT fk_opclass_indexed_codes_code FOREIGN KEY (code) REFERENCES codes(code)
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
CREATE TABLE collated_indexed_codes (
|
|
126
|
+
id SERIAL PRIMARY KEY,
|
|
127
|
+
code TEXT,
|
|
128
|
+
CONSTRAINT fk_collated_indexed_codes_code FOREIGN KEY (code) REFERENCES codes(code)
|
|
129
|
+
);
|
|
130
|
+
|
|
63
131
|
CREATE TABLE customers (
|
|
64
132
|
id SERIAL PRIMARY KEY,
|
|
65
133
|
name VARCHAR(255)
|
|
@@ -82,6 +150,25 @@ CREATE TABLE events (
|
|
|
82
150
|
);
|
|
83
151
|
|
|
84
152
|
CREATE INDEX index_posts_on_user_id ON posts(user_id, topic_id);
|
|
153
|
+
CREATE INDEX index_expression_indexed_posts_on_topic_id_expression ON expression_indexed_posts((topic_id::text));
|
|
154
|
+
CREATE INDEX index_expr_not_null_partial_posts_on_topic_id ON expression_not_null_partial_indexed_posts((topic_id::text)) WHERE topic_id IS NOT NULL;
|
|
155
|
+
CREATE INDEX index_partial_indexed_posts_on_topic_id ON partial_indexed_posts(topic_id) WHERE id > 0;
|
|
156
|
+
CREATE INDEX index_sorted_indexed_posts_on_topic_id ON sorted_indexed_posts(topic_id DESC NULLS LAST);
|
|
157
|
+
CREATE INDEX index_not_null_partial_indexed_posts_on_topic_id ON not_null_partial_indexed_posts(topic_id) WHERE topic_id IS NOT NULL;
|
|
158
|
+
CREATE INDEX index_null_partial_indexed_posts_on_topic_id ON null_partial_indexed_posts(topic_id) WHERE topic_id IS NULL;
|
|
159
|
+
CREATE INDEX index_included_indexed_posts_on_topic_id ON included_indexed_posts(topic_id) INCLUDE (id);
|
|
160
|
+
CREATE INDEX index_opclass_indexed_codes_on_code ON opclass_indexed_codes(code text_pattern_ops);
|
|
161
|
+
CREATE INDEX index_collated_indexed_codes_on_code ON collated_indexed_codes(code COLLATE "C");
|
|
162
|
+
|
|
163
|
+
-- Advanced index forms used to verify catalog-based index metadata parsing.
|
|
164
|
+
CREATE INDEX index_users_on_company_id_desc ON users(company_id DESC NULLS LAST);
|
|
165
|
+
CREATE INDEX index_users_on_lower_email ON users((lower(email)));
|
|
166
|
+
CREATE INDEX index_users_on_email_partial ON users(email) WHERE customer_id IS NOT NULL;
|
|
167
|
+
CREATE INDEX index_users_on_email_pattern ON users(email text_pattern_ops);
|
|
168
|
+
CREATE INDEX index_posts_on_external_id_desc ON posts(external_id DESC NULLS LAST);
|
|
169
|
+
CREATE INDEX index_posts_on_user_id_desc_and_title_pattern ON posts(user_id DESC, title COLLATE "C" text_pattern_ops);
|
|
170
|
+
CREATE INDEX index_users_on_email_collate_c ON users(email COLLATE "C");
|
|
171
|
+
CREATE INDEX index_users_on_email_include_customer_id ON users(email) INCLUDE (customer_id);
|
|
85
172
|
SQL
|
|
86
173
|
|
|
87
174
|
RubyPgExtras.connection.exec(DB_SCHEMA)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby-pg-extras
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- pawurb
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-07-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: pg
|
|
@@ -164,6 +164,8 @@ files:
|
|
|
164
164
|
- lib/ruby_pg_extras/queries/total_index_size.sql
|
|
165
165
|
- lib/ruby_pg_extras/queries/total_table_size.sql
|
|
166
166
|
- lib/ruby_pg_extras/queries/unused_indexes.sql
|
|
167
|
+
- lib/ruby_pg_extras/queries/update_stats.sql
|
|
168
|
+
- lib/ruby_pg_extras/queries/update_stats_legacy.sql
|
|
167
169
|
- lib/ruby_pg_extras/queries/vacuum_io_stats.sql
|
|
168
170
|
- lib/ruby_pg_extras/queries/vacuum_io_stats_legacy.sql
|
|
169
171
|
- lib/ruby_pg_extras/queries/vacuum_progress.sql
|