rails-pg-extras 1.3.0 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb4905b231d556cd0a389c53a77b59e74f6d11faf45d6e3fa9e17b456cd0349a
4
- data.tar.gz: 94e5c6c7ba1d48f403b069b5f7b7d24ae25e20f072166cf59d54fa891bf4662a
3
+ metadata.gz: ec78b739d900e56a89e3a2afd0f714538175d7ea7a816cd00115982ead78f0ed
4
+ data.tar.gz: ee936f6c5b7d6f48643d1dbe9a3e8245d36cb2369ec8675b3018b5ea9dad8c2a
5
5
  SHA512:
6
- metadata.gz: 3c41ba2e65e0d892690469fb232d09e58e02aa138ee17155014795963fc86a9be94d4c1d6482ca6e3564ab14a8b9263e1f7828c18ab7173cc3d0f16190ad4e12
7
- data.tar.gz: 1aa1554a5c26f89501e59462ed4af2efc90b7d3c16b07922d71a3c7d2140096ffac47c19584edda2b4af0bc45261ea8c35f48431c94451ba86d900b51dd5a705
6
+ metadata.gz: 98dae06049bf799eca77dfa53b7eb93ce9393c8fdd57e33bf70f993aba6067a507e3e6bb87b8cefee17868453337ca377ad315d9ef356b8980ecf14c4314f1a5
7
+ data.tar.gz: c34522f7495a1782e215fe07ccfcb0d8bdad630f1ba456e2e8609398137f2dd8cf869c64f0a823a689c814a84eec87bae8dda280150ce1260f4ae2213dd49520
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
  ```
93
+ RailsPGExtras.cache_hit
94
+
86
95
  $ rake pg_extras:cache_hit
87
96
 
88
97
  name | ratio
@@ -98,6 +107,8 @@ This command provides information on the efficiency of the buffer cache, for bot
98
107
 
99
108
  ```
100
109
 
110
+ RailsPGExtras.index_cache_hit
111
+
101
112
  $ rake pg_extras:index_cache_hit
102
113
 
103
114
  | name | buffer_hits | block_reads | total_read | ratio |
@@ -114,6 +125,8 @@ The same as `cache_hit` with each table's indexes cache hit info displayed separ
114
125
 
115
126
  ```
116
127
 
128
+ RailsPGExtras.table_cache_hit
129
+
117
130
  $ rake pg_extras:table_cache_hit
118
131
 
119
132
  | name | buffer_hits | block_reads | total_read | ratio |
@@ -129,6 +142,8 @@ The same as `cache_hit` with each table's cache hit info displayed seperately.
129
142
  ### `index_usage`
130
143
 
131
144
  ```
145
+ RailsPGExtras.index_usage
146
+
132
147
  $ rake pg_extras:index_usage
133
148
 
134
149
  relname | percent_of_times_index_used | rows_in_table
@@ -146,6 +161,8 @@ This command provides information on the efficiency of indexes, represented as w
146
161
  ### `locks`
147
162
 
148
163
  ```
164
+ RailsPGExtras.locks
165
+
149
166
  $ rake pg_extras:locks
150
167
 
151
168
  procpid | relname | transactionid | granted | query_snippet | mode | age
@@ -164,6 +181,8 @@ This command displays queries that have taken out an exclusive lock on a relatio
164
181
  ### `all_locks`
165
182
 
166
183
  ```
184
+ RailsPGExtras.all_locks
185
+
167
186
  $ rake pg_extras:all_locks
168
187
  ```
169
188
 
@@ -172,6 +191,8 @@ This command displays all the current locks, regardless of their type.
172
191
  ### `outliers`
173
192
 
174
193
  ```
194
+ RubyPGExtras.outliers(args: { limit: 20 })
195
+
175
196
  $ rake pg_extras:outliers
176
197
 
177
198
  qry | exec_time | prop_exec_time | ncalls | sync_io_time
@@ -192,6 +213,8 @@ Typically, an efficient query will have an appropriate ratio of calls to total e
192
213
  ### `calls`
193
214
 
194
215
  ```
216
+ RubyPGExtras.calls(args: { limit: 10 })
217
+
195
218
  $ rake pg_extras:calls
196
219
 
197
220
  qry | exec_time | prop_exec_time | ncalls | sync_io_time
@@ -209,6 +232,8 @@ This command is much like `pg:outliers`, but ordered by the number of times a st
209
232
  ### `blocking`
210
233
 
211
234
  ```
235
+ RubyPGExtras.blocking
236
+
212
237
  $ rake pg_extras:blocking
213
238
 
214
239
  blocked_pid | blocking_statement | blocking_duration | blocking_pid | blocked_statement | blocked_duration
@@ -222,6 +247,8 @@ This command displays statements that are currently holding locks that other sta
222
247
  #### `total_index_size`
223
248
 
224
249
  ```
250
+ RubyPGExtras.total_index_size
251
+
225
252
  $ rake pg_extras:total_index_size
226
253
 
227
254
  size
@@ -235,6 +262,8 @@ This command displays the total size of all indexes on the database, in MB. It i
235
262
  ### `index_size`
236
263
 
237
264
  ```
265
+ RubyPGExtras.index_size
266
+
238
267
  $ rake pg_extras:index_size
239
268
  name | size
240
269
  ---------------------------------------------------------------+---------
@@ -256,6 +285,8 @@ This command displays the size of each each index in the database, in MB. It is
256
285
  ### `table_size`
257
286
 
258
287
  ```
288
+ RubyPGExtras.table_size
289
+
259
290
  $ rake pg_extras:table_size
260
291
 
261
292
  name | size
@@ -273,6 +304,8 @@ This command displays the size of each table and materialized view in the databa
273
304
  ### `table_indexes_size`
274
305
 
275
306
  ```
307
+ RubyPGExtras.table_indexes_size
308
+
276
309
  $ rake pg_extras:table_indexes_size
277
310
 
278
311
  table | indexes_size
@@ -290,6 +323,8 @@ This command displays the total size of indexes for each table and materialized
290
323
  ### `total_table_size`
291
324
 
292
325
  ```
326
+ RubyPGExtras.total_table_size
327
+
293
328
  $ rake pg_extras:total_table_size
294
329
 
295
330
  name | size
@@ -307,6 +342,8 @@ This command displays the total size of each table and materialized view in the
307
342
  ### `unused_indexes`
308
343
 
309
344
  ```
345
+ RubyPGExtras.unused_indexes(args: { min_scans: 20 })
346
+
310
347
  $ rake pg_extras:unused_indexes
311
348
 
312
349
  table | index | index_size | index_scans
@@ -319,9 +356,29 @@ $ rake pg_extras:unused_indexes
319
356
 
320
357
  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
358
 
359
+ ### `null_indexes`
360
+
361
+ ```ruby
362
+
363
+ RailsPGExtras.null_indexes(args: { min_relation_size_mb: 10 })
364
+
365
+ $ rake pg_extras:null_indexes
366
+
367
+ oid | index | index_size | unique | indexed_column | null_frac | expected_saving
368
+ ---------+--------------------+------------+--------+----------------+-----------+-----------------
369
+ 183764 | users_reset_token | 1445 MB | t | reset_token | 97.00% | 1401 MB
370
+ 88732 | plan_cancelled_at | 539 MB | f | cancelled_at | 8.30% | 44 MB
371
+ 9827345 | users_email | 18 MB | t | email | 28.67% | 5160 kB
372
+
373
+ ```
374
+
375
+ This commands 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. [Source and more info](https://hakibenita.com/postgresql-unused-index-size).
376
+
322
377
  ### `seq_scans`
323
378
 
324
379
  ```
380
+ RubyPGExtras.seq_scans
381
+
325
382
  $ rake pg_extras:seq_scans
326
383
 
327
384
  name | count
@@ -350,6 +407,8 @@ This command displays the number of sequential scans recorded against all tables
350
407
  ### `long_running_queries`
351
408
 
352
409
  ```
410
+ RubyPGExtras.long_running_queries(args: { threshold: "200 milliseconds" })
411
+
353
412
  $ rake pg_extras:long_running_queries
354
413
 
355
414
  pid | duration | query
@@ -365,6 +424,8 @@ This command displays currently running queries, that have been running for long
365
424
  ### `records_rank`
366
425
 
367
426
  ```
427
+ RubyPGExtras.records_rank
428
+
368
429
  $ rake pg_extras:records_rank
369
430
 
370
431
  name | estimated_count
@@ -383,6 +444,8 @@ This command displays an estimated count of rows per table, descending by estima
383
444
  ### `bloat`
384
445
 
385
446
  ```
447
+ RubyPGExtras.bloat
448
+
386
449
  $ rake pg_extras:bloat
387
450
 
388
451
  type | schemaname | object_name | bloat | waste
@@ -400,6 +463,8 @@ This command displays an estimation of table "bloat" – space allocated to a re
400
463
  ### `vacuum_stats`
401
464
 
402
465
  ```
466
+ RubyPGExtras.vacuum_stats
467
+
403
468
  $ rake pg_extras:vacuum_stats
404
469
 
405
470
  schema | table | last_vacuum | last_autovacuum | rowcount | dead_rowcount | autovacuum_threshold | expect_autovacuum
@@ -425,10 +490,15 @@ This commands kills all the currently active connections to the database. It can
425
490
 
426
491
  ### `extensions`
427
492
 
428
- ```ruby
493
+ ```
429
494
 
430
495
  RailsPGExtras.extensions
431
496
 
497
+ $ rake pg_extras:extensions
498
+
499
+ | pg_stat_statements | 1.7 | 1.7 | track execution statistics of all SQL statements executed
500
+ (truncated results for brevity)
501
+
432
502
  ```
433
503
 
434
504
  This command lists all the currently installed and available PostgreSQL extensions.
@@ -436,6 +506,8 @@ This command lists all the currently installed and available PostgreSQL extensio
436
506
  ### mandelbrot
437
507
 
438
508
  ```
509
+ RailsPGExtras.mandelbrot
510
+
439
511
  $ rake pg_extras:mandelbrot
440
512
  ```
441
513
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsPGExtras
4
- VERSION = "1.3.0"
4
+ VERSION = "1.5.2"
5
5
  end
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.0
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawurb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-22 00:00:00.000000000 Z
11
+ date: 2021-02-13 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.0
19
+ version: 1.5.2
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.0
26
+ version: 1.5.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement