ruby-pg-extras 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +24 -18
- data/lib/ruby-pg-extras.rb +1 -1
- data/lib/ruby-pg-extras/queries/kill_all.sql +6 -0
- data/lib/ruby-pg-extras/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fe955faca71da76601e1e7d55ca59608a05ead32482d21bcba4fb86763b2916
|
4
|
+
data.tar.gz: c3605758915cee4edcc15e12424513acf5ba26b65d36adb52d8af626807513f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6414a45110bcd0404f3d36f3f074f65ed86560989c2e25f245c38d2ea694cdac961c94d58790235d3e5d80937ca62f27f0565dc007a0e8a9f32ecdeca1a9a711
|
7
|
+
data.tar.gz: 1808fb4368882f5727926c8722e018be2d25b98395374df129c8cd9238568d43cec29cc3bfae79aa775ec6100958579818aa158daeb84980c1a478dedaf053f5
|
data/README.md
CHANGED
@@ -6,15 +6,15 @@ Queries can be used to obtain information about a Postgres instance, that may be
|
|
6
6
|
|
7
7
|
Are you riding on Rails? Check out the [Rails version](https://github.com/pawurb/rails-pg-extras).
|
8
8
|
|
9
|
-
|
9
|
+
## Installation
|
10
10
|
|
11
11
|
In your Gemfile
|
12
12
|
|
13
13
|
```ruby
|
14
|
-
gem
|
14
|
+
gem "ruby-pg-extras"
|
15
15
|
```
|
16
16
|
|
17
|
-
|
17
|
+
## Usage
|
18
18
|
|
19
19
|
Gem expects the `ENV['DATABASE_URL']` value in the following format:
|
20
20
|
|
@@ -60,9 +60,9 @@ RubyPGExtras.cache_hit(in_format: :raw) =>
|
|
60
60
|
#<PG::Result:0x00007f75777f7328 status=PGRES_TUPLES_OK ntuples=2 nfields=2 cmd_tuples=2>
|
61
61
|
```
|
62
62
|
|
63
|
-
|
63
|
+
## Available methods
|
64
64
|
|
65
|
-
|
65
|
+
### `cache_hit`
|
66
66
|
|
67
67
|
```ruby
|
68
68
|
|
@@ -77,7 +77,7 @@ RubyPGExtras.cache_hit
|
|
77
77
|
|
78
78
|
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.
|
79
79
|
|
80
|
-
|
80
|
+
### `index_cache_hit`
|
81
81
|
|
82
82
|
```ruby
|
83
83
|
|
@@ -93,7 +93,7 @@ RubyPGExtras.index_cache_hit
|
|
93
93
|
|
94
94
|
The same as `cache_hit` with each table's indexes cache hit info displayed seperately.
|
95
95
|
|
96
|
-
|
96
|
+
### `table_cache_hit`
|
97
97
|
|
98
98
|
```ruby
|
99
99
|
|
@@ -109,7 +109,7 @@ RubyPGExtras.table_cache_hit
|
|
109
109
|
|
110
110
|
The same as `cache_hit` with each table's cache hit info displayed seperately.
|
111
111
|
|
112
|
-
|
112
|
+
### `index_usage`
|
113
113
|
|
114
114
|
```ruby
|
115
115
|
|
@@ -212,7 +212,7 @@ RubyPGExtras.blocking
|
|
212
212
|
|
213
213
|
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.
|
214
214
|
|
215
|
-
|
215
|
+
### `total_index_size`
|
216
216
|
|
217
217
|
```ruby
|
218
218
|
|
@@ -341,7 +341,7 @@ RubyPGExtras.seq_scans
|
|
341
341
|
|
342
342
|
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 underindexed, and it may be worth investigating queries that read from these tables.
|
343
343
|
|
344
|
-
### long_running_queries
|
344
|
+
### `long_running_queries`
|
345
345
|
|
346
346
|
```ruby
|
347
347
|
|
@@ -358,7 +358,7 @@ RubyPGExtras.long_running_queries
|
|
358
358
|
|
359
359
|
This command displays currently running queries, that have been running for longer than 5 minutes, descending by duration. Very long running queries can be a source of multiple issues, such as preventing DDL statements completing or vacuum being unable to update `relfrozenxid`.
|
360
360
|
|
361
|
-
### records_rank
|
361
|
+
### `records_rank`
|
362
362
|
|
363
363
|
```ruby
|
364
364
|
|
@@ -377,7 +377,7 @@ RubyPGExtras.records_rank
|
|
377
377
|
|
378
378
|
This command displays an estimated count of rows per table, descending by estimated count. The estimated count is derived from `n_live_tup`, which is updated by vacuum operations. Due to the way `n_live_tup` is populated, sparse vs. dense pages can result in estimations that are significantly out from the real count of rows.
|
379
379
|
|
380
|
-
### bloat
|
380
|
+
### `bloat`
|
381
381
|
|
382
382
|
```ruby
|
383
383
|
|
@@ -396,7 +396,7 @@ RubyPGExtras.bloat
|
|
396
396
|
|
397
397
|
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.
|
398
398
|
|
399
|
-
### vacuum_stats
|
399
|
+
### `vacuum_stats`
|
400
400
|
|
401
401
|
```ruby
|
402
402
|
|
@@ -414,7 +414,17 @@ RubyPGExtras.vacuum_stats
|
|
414
414
|
|
415
415
|
This command displays statistics related to vacuum operations for each table, including an estiamtion of dead rows, last autovacuum and the current autovacuum threshold. This command can be useful when determining if current vacuum thresholds require adjustments, and to determine when the table was last vacuumed.
|
416
416
|
|
417
|
-
###
|
417
|
+
### `kill_all`
|
418
|
+
|
419
|
+
```ruby
|
420
|
+
|
421
|
+
RubyPGExtras.kill_all
|
422
|
+
|
423
|
+
```
|
424
|
+
|
425
|
+
This commands kills all the currently active connections to the database. It can be useful as a last resort when your database is stuck in a deadlock.
|
426
|
+
|
427
|
+
### `mandelbrot`
|
418
428
|
|
419
429
|
```ruby
|
420
430
|
|
@@ -429,7 +439,3 @@ This command outputs the Mandelbrot set, calculated through SQL.
|
|
429
439
|
* Does is not violate the Heroku PG Extras license?
|
430
440
|
|
431
441
|
The original plugin is MIT based so it means that copying and redistribution in any format is permitted.
|
432
|
-
|
433
|
-
## Disclaimer
|
434
|
-
|
435
|
-
This tool is in beta state.
|
data/lib/ruby-pg-extras.rb
CHANGED
@@ -14,7 +14,7 @@ module RubyPGExtras
|
|
14
14
|
long_running_queries mandelbrot outliers
|
15
15
|
records_rank seq_scans table_indexes_size
|
16
16
|
table_size total_index_size total_table_size
|
17
|
-
unused_indexes vacuum_stats
|
17
|
+
unused_indexes vacuum_stats kill_all
|
18
18
|
)
|
19
19
|
|
20
20
|
QUERIES.each do |query_name|
|
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: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pawurb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- lib/ruby-pg-extras/queries/index_cache_hit.sql
|
93
93
|
- lib/ruby-pg-extras/queries/index_size.sql
|
94
94
|
- lib/ruby-pg-extras/queries/index_usage.sql
|
95
|
+
- lib/ruby-pg-extras/queries/kill_all.sql
|
95
96
|
- lib/ruby-pg-extras/queries/locks.sql
|
96
97
|
- lib/ruby-pg-extras/queries/long_running_queries.sql
|
97
98
|
- lib/ruby-pg-extras/queries/mandelbrot.sql
|