rails-pg-extras 5.2.1 → 5.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +38 -23
- data/lib/rails_pg_extras/version.rb +1 -1
- data/marginalia-logs.png +0 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bcee4d55bf01b44d36cb44ddd18e2cb4e1332f279e1d64e24459ba699822b35
|
4
|
+
data.tar.gz: 1f11135781de014d57e8f9b2d78a9bebc686e7c4266fdb072d30d0551e1f4ca7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 915f068aa1146196e7a7e6e7fd7b53164995aef312d4bb4fce2865ed59328d50ecd398f8f1201a0ae179a8d4e14ee69fce4c9fe1e406c24d54bf1e2f5ee3d656
|
7
|
+
data.tar.gz: 626ffcd65d992f73ac75c8da877563d0e618add2259e6fda22a153ef9c671f067ca8bdfa63c7d517df57b77e2a2ffd464c60cadbc4c02ddb9532c6044ca22b0c
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ You can read this blog post for detailed step by step tutorial on how to [optimi
|
|
10
10
|
|
11
11
|
Optionally you can enable a visual interface:
|
12
12
|
|
13
|
-
![Web interface](https://github.com/pawurb/rails-pg-extras/raw/
|
13
|
+
![Web interface](https://github.com/pawurb/rails-pg-extras/raw/main/pg-extras-ui.png)
|
14
14
|
|
15
15
|
Alternative versions:
|
16
16
|
|
@@ -51,7 +51,7 @@ You should see the similar line in the output:
|
|
51
51
|
RailsPgExtras.add_extensions
|
52
52
|
```
|
53
53
|
|
54
|
-
By
|
54
|
+
By default a primary ActiveRecord database connection is used for running metadata queries, rake tasks and web UI. To connect to a different database you can specify an `ENV['RAILS_PG_EXTRAS_DATABASE_URL']` value in the following format:
|
55
55
|
|
56
56
|
```ruby
|
57
57
|
ENV["RAILS_PG_EXTRAS_DATABASE_URL"] = "postgresql://postgres:secret@localhost:5432/database_name"
|
@@ -113,7 +113,7 @@ RailsPgExtras.diagnose
|
|
113
113
|
$ rake pg_extras:diagnose
|
114
114
|
```
|
115
115
|
|
116
|
-
![Diagnose report](https://github.com/pawurb/rails-pg-extras/raw/
|
116
|
+
![Diagnose report](https://github.com/pawurb/rails-pg-extras/raw/main/rails-pg-extras-diagnose.png)
|
117
117
|
|
118
118
|
Keep reading to learn about methods that `diagnose` uses under the hood.
|
119
119
|
|
@@ -152,18 +152,18 @@ RailsPgExtras.measure_queries { User.limit(10).map(&:team) }
|
|
152
152
|
:queries=>
|
153
153
|
{"SELECT \"users\".* FROM \"users\" LIMIT $1"=>
|
154
154
|
{:count=>1,
|
155
|
-
:total_duration=>
|
156
|
-
:min_duration=>
|
157
|
-
:max_duration=>
|
158
|
-
:avg_duration=>
|
155
|
+
:total_duration=>1.9,
|
156
|
+
:min_duration=>1.9,
|
157
|
+
:max_duration=>1.9,
|
158
|
+
:avg_duration=>1.9},
|
159
159
|
"SELECT \"teams\".* FROM \"teams\" WHERE \"teams\".\"id\" = $1 LIMIT $2"=>
|
160
160
|
{:count=>10,
|
161
|
-
:total_duration=>
|
162
|
-
:min_duration=>0.
|
163
|
-
:max_duration=>1.
|
164
|
-
:avg_duration=>
|
165
|
-
:total_duration=>
|
166
|
-
:sql_duration=>
|
161
|
+
:total_duration=>0.94,
|
162
|
+
:min_duration=>0.62,
|
163
|
+
:max_duration=>1.37,
|
164
|
+
:avg_duration=>0.94}},
|
165
|
+
:total_duration=>13.35,
|
166
|
+
:sql_duration=>11.34}
|
167
167
|
|
168
168
|
RailsPgExtras.measure_queries { User.limit(10).includes(:team).map(&:team) }
|
169
169
|
|
@@ -171,21 +171,36 @@ RailsPgExtras.measure_queries { User.limit(10).includes(:team).map(&:team) }
|
|
171
171
|
:queries=>
|
172
172
|
{"SELECT \"users\".* FROM \"users\" LIMIT $1"=>
|
173
173
|
{:count=>1,
|
174
|
-
:total_duration=>3.
|
175
|
-
:min_duration=>3.
|
176
|
-
:max_duration=>3.
|
177
|
-
|
174
|
+
:total_duration=>3.43,
|
175
|
+
:min_duration=>3.43,
|
176
|
+
:max_duration=>3.43,
|
177
|
+
:avg_duration=>3.43},
|
178
178
|
"SELECT \"teams\".* FROM \"teams\" WHERE \"teams\".\"id\" IN ($1, $2, $3, $4, $5, $6, $7, $8)"=>
|
179
179
|
{:count=>1,
|
180
|
-
:total_duration=>2.
|
181
|
-
:min_duration=>2.
|
182
|
-
:max_duration=>2.
|
183
|
-
:avg_duration=>2.
|
184
|
-
:total_duration=>9.
|
185
|
-
:sql_duration=>6.
|
180
|
+
:total_duration=>2.59,
|
181
|
+
:min_duration=>2.59,
|
182
|
+
:max_duration=>2.59,
|
183
|
+
:avg_duration=>2.59}},
|
184
|
+
:total_duration=>9.75,
|
185
|
+
:sql_duration=>6.02}
|
186
186
|
|
187
187
|
```
|
188
188
|
|
189
|
+
Optionally, by including [Marginalia gem](https://github.com/basecamp/marginalia) and configuring it to display query backtraces:
|
190
|
+
|
191
|
+
`config/development.rb`
|
192
|
+
|
193
|
+
```ruby
|
194
|
+
|
195
|
+
Marginalia::Comment.components = [:line]
|
196
|
+
|
197
|
+
```
|
198
|
+
|
199
|
+
you can add this info to the output:
|
200
|
+
|
201
|
+
![Marginalia logs](https://github.com/pawurb/rails-pg-extras/raw/main/marginalia-logs.png)
|
202
|
+
|
203
|
+
|
189
204
|
### `table_info`
|
190
205
|
|
191
206
|
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.
|
data/marginalia-logs.png
ADDED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-pg-extras
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.2.
|
4
|
+
version: 5.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pawurb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-pg-extras
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 5.2.
|
19
|
+
version: 5.2.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 5.2.
|
26
|
+
version: 5.2.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- lib/rails_pg_extras/version.rb
|
107
107
|
- lib/rails_pg_extras/web.rb
|
108
108
|
- lib/rails_pg_extras/web/engine.rb
|
109
|
+
- marginalia-logs.png
|
109
110
|
- pg-extras-ui.png
|
110
111
|
- rails-pg-extras-diagnose.png
|
111
112
|
- rails-pg-extras.gemspec
|