rails-pg-extras 1.3.1 → 1.5.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 +136 -30
- data/lib/rails-pg-extras/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '039398a75ef2c3ce82ef8760784fc14d4d05496f590d64374a6863a4eb200b08'
|
4
|
+
data.tar.gz: 82d2d82c66aed09fff9276cf76a28ecb994175257ce9c0857cc5b3fd59d4b81e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25305f71d527acb17f81b8e9e9f8c2b1420f7e07d8a43924eb69043f9be63ea578482e63c68a2800f6adf8b00d53472895ee8a0897a26a7ec0ec750b5250b94e
|
7
|
+
data.tar.gz: 4d6f3706e52305a885da9351b5e752cffadef0a074bf1139d362622adb37baa0409e103f59458141811e875a01581560fdce6702884cfbffeda88da70f98ec35
|
data/README.md
CHANGED
@@ -78,11 +78,20 @@ RailsPGExtras.cache_hit(in_format: :raw) =>
|
|
78
78
|
#<PG::Result:0x00007f75777f7328 status=PGRES_TUPLES_OK ntuples=2 nfields=2 cmd_tuples=2>
|
79
79
|
```
|
80
80
|
|
81
|
+
Some methods accept an optional `args` param allowing you to customize queries:
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
RailsPGExtras.long_running_queries(args: { threshold: "200 milliseconds" })
|
85
|
+
|
86
|
+
```
|
87
|
+
|
81
88
|
## Available methods
|
82
89
|
|
83
90
|
### `cache_hit`
|
84
91
|
|
85
|
-
```
|
92
|
+
```ruby
|
93
|
+
RailsPGExtras.cache_hit
|
94
|
+
|
86
95
|
$ rake pg_extras:cache_hit
|
87
96
|
|
88
97
|
name | ratio
|
@@ -94,9 +103,13 @@ $ rake pg_extras:cache_hit
|
|
94
103
|
|
95
104
|
This command provides information on the efficiency of the buffer cache, for both index reads (`index hit rate`) as well as table reads (`table hit rate`). A low buffer cache hit ratio can be a sign that the Postgres instance is too small for the workload.
|
96
105
|
|
106
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#cache-hit)
|
107
|
+
|
97
108
|
### `index_cache_hit`
|
98
109
|
|
99
|
-
```
|
110
|
+
```ruby
|
111
|
+
|
112
|
+
RailsPGExtras.index_cache_hit
|
100
113
|
|
101
114
|
$ rake pg_extras:index_cache_hit
|
102
115
|
|
@@ -110,9 +123,13 @@ $ rake pg_extras:index_cache_hit
|
|
110
123
|
|
111
124
|
The same as `cache_hit` with each table's indexes cache hit info displayed separately.
|
112
125
|
|
126
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#cache-hit)
|
127
|
+
|
113
128
|
### `table_cache_hit`
|
114
129
|
|
115
|
-
```
|
130
|
+
```ruby
|
131
|
+
|
132
|
+
RailsPGExtras.table_cache_hit
|
116
133
|
|
117
134
|
$ rake pg_extras:table_cache_hit
|
118
135
|
|
@@ -126,9 +143,33 @@ $ rake pg_extras:table_cache_hit
|
|
126
143
|
|
127
144
|
The same as `cache_hit` with each table's cache hit info displayed seperately.
|
128
145
|
|
129
|
-
|
146
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#cache-hit)
|
147
|
+
|
148
|
+
### `db_settings`
|
149
|
+
|
150
|
+
```ruby
|
151
|
+
|
152
|
+
RailsPGExtras.db_settings
|
153
|
+
|
154
|
+
$ rake pg_extras:db_settings
|
155
|
+
|
156
|
+
name | setting | unit |
|
157
|
+
------------------------------+---------+------+
|
158
|
+
checkpoint_completion_target | 0.7 | |
|
159
|
+
default_statistics_target | 100 | |
|
160
|
+
effective_cache_size | 1350000 | 8kB |
|
161
|
+
effective_io_concurrency | 1 | |
|
162
|
+
(truncated results for brevity)
|
130
163
|
|
131
164
|
```
|
165
|
+
|
166
|
+
This method displays values for selected PostgreSQL settings. You can compare them with settings recommended by [PGTune](https://pgtune.leopard.in.ua/#/) and tweak values to improve performance.
|
167
|
+
|
168
|
+
### `index_usage`
|
169
|
+
|
170
|
+
```ruby
|
171
|
+
RailsPGExtras.index_usage
|
172
|
+
|
132
173
|
$ rake pg_extras:index_usage
|
133
174
|
|
134
175
|
relname | percent_of_times_index_used | rows_in_table
|
@@ -145,7 +186,9 @@ This command provides information on the efficiency of indexes, represented as w
|
|
145
186
|
|
146
187
|
### `locks`
|
147
188
|
|
148
|
-
```
|
189
|
+
```ruby
|
190
|
+
RailsPGExtras.locks
|
191
|
+
|
149
192
|
$ rake pg_extras:locks
|
150
193
|
|
151
194
|
procpid | relname | transactionid | granted | query_snippet | mode | age
|
@@ -161,9 +204,13 @@ $ rake pg_extras:locks
|
|
161
204
|
|
162
205
|
This command displays queries that have taken out an exclusive lock on a relation. Exclusive locks typically prevent other operations on that relation from taking place, and can be a cause of "hung" queries that are waiting for a lock to be granted.
|
163
206
|
|
207
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#deadlocks)
|
208
|
+
|
164
209
|
### `all_locks`
|
165
210
|
|
166
|
-
```
|
211
|
+
```ruby
|
212
|
+
RailsPGExtras.all_locks
|
213
|
+
|
167
214
|
$ rake pg_extras:all_locks
|
168
215
|
```
|
169
216
|
|
@@ -171,7 +218,9 @@ This command displays all the current locks, regardless of their type.
|
|
171
218
|
|
172
219
|
### `outliers`
|
173
220
|
|
174
|
-
```
|
221
|
+
```ruby
|
222
|
+
RubyPGExtras.outliers(args: { limit: 20 })
|
223
|
+
|
175
224
|
$ rake pg_extras:outliers
|
176
225
|
|
177
226
|
qry | exec_time | prop_exec_time | ncalls | sync_io_time
|
@@ -189,9 +238,13 @@ This command displays statements, obtained from `pg_stat_statements`, ordered by
|
|
189
238
|
|
190
239
|
Typically, an efficient query will have an appropriate ratio of calls to total execution time, with as little time spent on I/O as possible. Queries that have a high total execution time but low call count should be investigated to improve their performance. Queries that have a high proportion of execution time being spent on synchronous I/O should also be investigated.
|
191
240
|
|
241
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#missing-indexes)
|
242
|
+
|
192
243
|
### `calls`
|
193
244
|
|
194
|
-
```
|
245
|
+
```ruby
|
246
|
+
RubyPGExtras.calls(args: { limit: 10 })
|
247
|
+
|
195
248
|
$ rake pg_extras:calls
|
196
249
|
|
197
250
|
qry | exec_time | prop_exec_time | ncalls | sync_io_time
|
@@ -206,9 +259,13 @@ $ rake pg_extras:calls
|
|
206
259
|
|
207
260
|
This command is much like `pg:outliers`, but ordered by the number of times a statement has been called.
|
208
261
|
|
262
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#missing-indexes)
|
263
|
+
|
209
264
|
### `blocking`
|
210
265
|
|
211
|
-
```
|
266
|
+
```ruby
|
267
|
+
RubyPGExtras.blocking
|
268
|
+
|
212
269
|
$ rake pg_extras:blocking
|
213
270
|
|
214
271
|
blocked_pid | blocking_statement | blocking_duration | blocking_pid | blocked_statement | blocked_duration
|
@@ -219,9 +276,13 @@ $ rake pg_extras:blocking
|
|
219
276
|
|
220
277
|
This command displays statements that are currently holding locks that other statements are waiting to be released. This can be used in conjunction with `pg:locks` to determine which statements need to be terminated in order to resolve lock contention.
|
221
278
|
|
222
|
-
|
279
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#deadlocks)
|
280
|
+
|
281
|
+
### `total_index_size`
|
282
|
+
|
283
|
+
```ruby
|
284
|
+
RubyPGExtras.total_index_size
|
223
285
|
|
224
|
-
```
|
225
286
|
$ rake pg_extras:total_index_size
|
226
287
|
|
227
288
|
size
|
@@ -234,7 +295,9 @@ This command displays the total size of all indexes on the database, in MB. It i
|
|
234
295
|
|
235
296
|
### `index_size`
|
236
297
|
|
237
|
-
```
|
298
|
+
```ruby
|
299
|
+
RubyPGExtras.index_size
|
300
|
+
|
238
301
|
$ rake pg_extras:index_size
|
239
302
|
name | size
|
240
303
|
---------------------------------------------------------------+---------
|
@@ -255,7 +318,9 @@ This command displays the size of each each index in the database, in MB. It is
|
|
255
318
|
|
256
319
|
### `table_size`
|
257
320
|
|
258
|
-
```
|
321
|
+
```ruby
|
322
|
+
RubyPGExtras.table_size
|
323
|
+
|
259
324
|
$ rake pg_extras:table_size
|
260
325
|
|
261
326
|
name | size
|
@@ -272,7 +337,9 @@ This command displays the size of each table and materialized view in the databa
|
|
272
337
|
|
273
338
|
### `table_indexes_size`
|
274
339
|
|
275
|
-
```
|
340
|
+
```ruby
|
341
|
+
RubyPGExtras.table_indexes_size
|
342
|
+
|
276
343
|
$ rake pg_extras:table_indexes_size
|
277
344
|
|
278
345
|
table | indexes_size
|
@@ -289,7 +356,9 @@ This command displays the total size of indexes for each table and materialized
|
|
289
356
|
|
290
357
|
### `total_table_size`
|
291
358
|
|
292
|
-
```
|
359
|
+
```ruby
|
360
|
+
RubyPGExtras.total_table_size
|
361
|
+
|
293
362
|
$ rake pg_extras:total_table_size
|
294
363
|
|
295
364
|
name | size
|
@@ -306,7 +375,9 @@ This command displays the total size of each table and materialized view in the
|
|
306
375
|
|
307
376
|
### `unused_indexes`
|
308
377
|
|
309
|
-
```
|
378
|
+
```ruby
|
379
|
+
RubyPGExtras.unused_indexes(args: { min_scans: 20 })
|
380
|
+
|
310
381
|
$ rake pg_extras:unused_indexes
|
311
382
|
|
312
383
|
table | index | index_size | index_scans
|
@@ -319,9 +390,33 @@ $ rake pg_extras:unused_indexes
|
|
319
390
|
|
320
391
|
This command displays indexes that have < 50 scans recorded against them, and are greater than 5 pages in size, ordered by size relative to the number of index scans. This command is generally useful for eliminating indexes that are unused, which can impact write performance, as well as read performance should they occupy space in memory.
|
321
392
|
|
322
|
-
|
393
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#unused-indexes)
|
394
|
+
|
395
|
+
### `null_indexes`
|
396
|
+
|
397
|
+
```ruby
|
398
|
+
|
399
|
+
RailsPGExtras.null_indexes(args: { min_relation_size_mb: 10 })
|
400
|
+
|
401
|
+
$ rake pg_extras:null_indexes
|
402
|
+
|
403
|
+
oid | index | index_size | unique | indexed_column | null_frac | expected_saving
|
404
|
+
---------+--------------------+------------+--------+----------------+-----------+-----------------
|
405
|
+
183764 | users_reset_token | 1445 MB | t | reset_token | 97.00% | 1401 MB
|
406
|
+
88732 | plan_cancelled_at | 539 MB | f | cancelled_at | 8.30% | 44 MB
|
407
|
+
9827345 | users_email | 18 MB | t | email | 28.67% | 5160 kB
|
323
408
|
|
324
409
|
```
|
410
|
+
|
411
|
+
This command displays indexes that contain `NULL` values. A high ratio of `NULL` values means that using a partial index excluding them will be beneficial in case they are not used for searching.
|
412
|
+
|
413
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#null-indexes)
|
414
|
+
|
415
|
+
### `seq_scans`
|
416
|
+
|
417
|
+
```ruby
|
418
|
+
RubyPGExtras.seq_scans
|
419
|
+
|
325
420
|
$ rake pg_extras:seq_scans
|
326
421
|
|
327
422
|
name | count
|
@@ -334,22 +429,18 @@ $ rake pg_extras:seq_scans
|
|
334
429
|
messages | 3922247
|
335
430
|
contests_customers | 2915972
|
336
431
|
classroom_goals | 2142014
|
337
|
-
contests | 1370267
|
338
|
-
goals | 1112659
|
339
|
-
districts | 158995
|
340
|
-
rollup_reports | 115942
|
341
|
-
customers | 93847
|
342
|
-
schools | 92984
|
343
|
-
classrooms | 92982
|
344
|
-
customer_settings | 91226
|
345
432
|
(truncated results for brevity)
|
346
433
|
```
|
347
434
|
|
348
435
|
This command displays the number of sequential scans recorded against all tables, descending by count of sequential scans. Tables that have very high numbers of sequential scans may be under-indexed, and it may be worth investigating queries that read from these tables.
|
349
436
|
|
437
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#missing-indexes)
|
438
|
+
|
350
439
|
### `long_running_queries`
|
351
440
|
|
352
|
-
```
|
441
|
+
```ruby
|
442
|
+
RubyPGExtras.long_running_queries(args: { threshold: "200 milliseconds" })
|
443
|
+
|
353
444
|
$ rake pg_extras:long_running_queries
|
354
445
|
|
355
446
|
pid | duration | query
|
@@ -364,7 +455,9 @@ This command displays currently running queries, that have been running for long
|
|
364
455
|
|
365
456
|
### `records_rank`
|
366
457
|
|
367
|
-
```
|
458
|
+
```ruby
|
459
|
+
RubyPGExtras.records_rank
|
460
|
+
|
368
461
|
$ rake pg_extras:records_rank
|
369
462
|
|
370
463
|
name | estimated_count
|
@@ -382,7 +475,9 @@ This command displays an estimated count of rows per table, descending by estima
|
|
382
475
|
|
383
476
|
### `bloat`
|
384
477
|
|
385
|
-
```
|
478
|
+
```ruby
|
479
|
+
RubyPGExtras.bloat
|
480
|
+
|
386
481
|
$ rake pg_extras:bloat
|
387
482
|
|
388
483
|
type | schemaname | object_name | bloat | waste
|
@@ -397,9 +492,13 @@ $ rake pg_extras:bloat
|
|
397
492
|
|
398
493
|
This command displays an estimation of table "bloat" – space allocated to a relation that is full of dead tuples, that has yet to be reclaimed. Tables that have a high bloat ratio, typically 10 or greater, should be investigated to see if vacuuming is aggressive enough, and can be a sign of high table churn.
|
399
494
|
|
495
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#bloat)
|
496
|
+
|
400
497
|
### `vacuum_stats`
|
401
498
|
|
402
|
-
```
|
499
|
+
```ruby
|
500
|
+
RubyPGExtras.vacuum_stats
|
501
|
+
|
403
502
|
$ rake pg_extras:vacuum_stats
|
404
503
|
|
405
504
|
schema | table | last_vacuum | last_autovacuum | rowcount | dead_rowcount | autovacuum_threshold | expect_autovacuum
|
@@ -429,13 +528,20 @@ This commands kills all the currently active connections to the database. It can
|
|
429
528
|
|
430
529
|
RailsPGExtras.extensions
|
431
530
|
|
531
|
+
$ rake pg_extras:extensions
|
532
|
+
|
533
|
+
| pg_stat_statements | 1.7 | 1.7 | track execution statistics of all SQL statements executed
|
534
|
+
(truncated results for brevity)
|
535
|
+
|
432
536
|
```
|
433
537
|
|
434
538
|
This command lists all the currently installed and available PostgreSQL extensions.
|
435
539
|
|
436
540
|
### mandelbrot
|
437
541
|
|
438
|
-
```
|
542
|
+
```ruby
|
543
|
+
RailsPGExtras.mandelbrot
|
544
|
+
|
439
545
|
$ rake pg_extras:mandelbrot
|
440
546
|
```
|
441
547
|
|
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: 1.3
|
4
|
+
version: 1.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pawurb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-02-16 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: 1.3
|
19
|
+
version: 1.5.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: 1.3
|
26
|
+
version: 1.5.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activerecord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|