ruby-pg-extras 3.2.3 → 3.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +32 -0
- data/lib/ruby-pg-extras/diagnose_data.rb +1 -1
- data/lib/ruby-pg-extras/index_info.rb +1 -1
- data/lib/ruby-pg-extras/version.rb +1 -1
- data/ruby-pg-extras.gemspec +21 -17
- data/spec/diagnose_data_spec.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f995f931c2dc41eaf38f0a9618aa591b351c953bc5f2c5c33381e3180137291
|
4
|
+
data.tar.gz: 1a0bd0e16237505d6f5bc6a1d7f99be0b09e4dc0985076c61d3295fe6edcbca0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecde58728d9d1929477a994d28b318bc978dfd645d853628ac31f6ba88ec2189fb50749b71dae5021f42aa0925c77eb1712013ce07715352ca42526b6d9d8b40
|
7
|
+
data.tar.gz: 0d106567d3f9bdb9f0c691a0d4dcf1eb7ca53b4baffb823140648322b49a5b26ecaacdd6c70e9aaffa686f225db04b75cd101e90035a83919cd45c2af4a9fbf8
|
data/README.md
CHANGED
@@ -112,6 +112,38 @@ Keep reading to learn about methods that `diagnose` uses under the hood.
|
|
112
112
|
|
113
113
|
## Available methods
|
114
114
|
|
115
|
+
### `table_info`
|
116
|
+
|
117
|
+
This method displays metadata metrics for all or a selected table. You can use it to check the table's size, its cache hit metrics, and whether it is correctly indexed. Many sequential scans or no index scans are potential indicators of misconfigured indexes. This method aggregates data provided by other methods in an easy to analyze summary format.
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
RubyPGExtras.table_info(args: { table_name: "users" })
|
121
|
+
|
122
|
+
| Table name | Table size | Table cache hit | Indexes cache hit | Estimated rows | Sequential scans | Indexes scans |
|
123
|
+
+------------+------------+-------------------+--------------------+----------------+------------------+---------------+
|
124
|
+
| users | 2432 kB | 0.999966685701511 | 0.9988780464661853 | 16650 | 2128 | 512496 |
|
125
|
+
|
126
|
+
```
|
127
|
+
|
128
|
+
### `index_info`
|
129
|
+
|
130
|
+
This method returns summary info about database indexes. You can check index size, how often it is used and what percentage of its total size are NULL values. Like the previous method, it aggregates data from other helper methods in an easy-to-digest format.
|
131
|
+
|
132
|
+
```ruby
|
133
|
+
|
134
|
+
RubyPGExtras.index_info(args: { table_name: "users" })
|
135
|
+
|
136
|
+
| Index name | Table name | Columns | Index size | Index scans | Null frac |
|
137
|
+
+-------------------------------+------------+----------------+------------+-------------+-----------+
|
138
|
+
| users_pkey | users | id | 1152 kB | 163007 | 0.00% |
|
139
|
+
| index_users_on_slack_id | users | slack_id | 1080 kB | 258870 | 0.00% |
|
140
|
+
| index_users_on_team_id | users | team_id | 816 kB | 70962 | 0.00% |
|
141
|
+
| index_users_on_uuid | users | uuid | 1032 kB | 0 | 0.00% |
|
142
|
+
| index_users_on_block_uuid | users | block_uuid | 776 kB | 19502 | 100.00% |
|
143
|
+
| index_users_on_api_auth_token | users | api_auth_token | 1744 kB | 156 | 0.00% |
|
144
|
+
|
145
|
+
```
|
146
|
+
|
115
147
|
### `cache_hit`
|
116
148
|
|
117
149
|
```ruby
|
@@ -118,7 +118,7 @@ module RubyPGExtras
|
|
118
118
|
in_format: :hash,
|
119
119
|
args: { min_scans: PG_EXTRAS_UNUSED_INDEXES_MAX_SCANS }
|
120
120
|
).select do |i|
|
121
|
-
Filesize.from(i.fetch("index_size")).to_i >= PG_EXTRAS_UNUSED_INDEXES_MIN_SIZE_BYTES
|
121
|
+
Filesize.from(i.fetch("index_size").sub("bytes", "").strip).to_i >= PG_EXTRAS_UNUSED_INDEXES_MIN_SIZE_BYTES
|
122
122
|
end
|
123
123
|
|
124
124
|
if indexes.count == 0
|
data/ruby-pg-extras.gemspec
CHANGED
@@ -3,21 +3,25 @@ lib = File.expand_path('../lib', __FILE__)
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
require 'ruby-pg-extras/version'
|
5
5
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "ruby-pg-extras"
|
8
|
+
s.version = RubyPGExtras::VERSION
|
9
|
+
s.authors = ["pawurb"]
|
10
|
+
s.email = ["contact@pawelurbanek.com"]
|
11
|
+
s.summary = %q{ Ruby PostgreSQL performance database insights }
|
12
|
+
s.description = %q{ Ruby port of Heroku PG Extras. The goal of this project is to provide a powerful insights into PostgreSQL database for Ruby on Rails apps that are not using the default Heroku PostgreSQL plugin. }
|
13
|
+
s.homepage = "http://github.com/pawurb/ruby-pg-extras"
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = s.files.grep(%r{^(spec)/})
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.license = "MIT"
|
18
|
+
s.add_dependency "pg"
|
19
|
+
s.add_dependency "filesize"
|
20
|
+
s.add_dependency "terminal-table"
|
21
|
+
s.add_development_dependency "rake"
|
22
|
+
s.add_development_dependency "rspec"
|
23
|
+
|
24
|
+
if s.respond_to?(:metadata=)
|
25
|
+
s.metadata = { "rubygems_mfa_required" => "true" }
|
26
|
+
end
|
23
27
|
end
|
data/spec/diagnose_data_spec.rb
CHANGED
@@ -13,7 +13,7 @@ describe RubyPGExtras::DiagnoseData do
|
|
13
13
|
expect(RubyPGExtras).to receive(:unused_indexes) {
|
14
14
|
[
|
15
15
|
{ "table" => "public.plans", "index" => "index_plans_on_payer_id", "index_size" => "16 MB", "index_scans" => 0 },
|
16
|
-
{ "table" => "public.feedbacks", "index" => "index_feedbacks_on_target_id", "index_size" => "
|
16
|
+
{ "table" => "public.feedbacks", "index" => "index_feedbacks_on_target_id", "index_size" => "111180 bytes", "index_scans" => 1 },
|
17
17
|
{ "table" => "public.channels", "index" => "index_channels_on_slack_id", "index_size" => "56 MB", "index_scans" => 7}
|
18
18
|
]
|
19
19
|
}
|
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: 3.2.
|
4
|
+
version: 3.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pawurb
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -152,8 +152,9 @@ files:
|
|
152
152
|
homepage: http://github.com/pawurb/ruby-pg-extras
|
153
153
|
licenses:
|
154
154
|
- MIT
|
155
|
-
metadata:
|
156
|
-
|
155
|
+
metadata:
|
156
|
+
rubygems_mfa_required: 'true'
|
157
|
+
post_install_message:
|
157
158
|
rdoc_options: []
|
158
159
|
require_paths:
|
159
160
|
- lib
|
@@ -169,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
170
|
version: '0'
|
170
171
|
requirements: []
|
171
172
|
rubygems_version: 3.1.6
|
172
|
-
signing_key:
|
173
|
+
signing_key:
|
173
174
|
specification_version: 4
|
174
175
|
summary: Ruby PostgreSQL performance database insights
|
175
176
|
test_files:
|