ruby-pg-extras 1.5.2 → 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 +41 -1
- data/lib/ruby-pg-extras.rb +1 -1
- data/lib/ruby-pg-extras/queries/db_settings.sql +9 -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: 3de471f9f4d008d006000667b4b52d4e0d8aec0c5dc9ef55ce6045e5e8f96994
|
4
|
+
data.tar.gz: bb78196a09f0af1d7f4be623f1794223b3db074d19eb439e59670b8e960d06e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ed2d3f75a540b6e8b22db825a1479a53649ee3ddde59ca7783301f5e42d89f8a8c1d40e11b42a5f1340f3b72d866531a6878c57ccfb211f43ca00d21d82c177
|
7
|
+
data.tar.gz: 5f6618ededb729f9d085cfdc5c5c722065ccd8beee6cb191bdfc3e6e58700fa2468d0f5aa3f7829fc9d520d7fb66fe248d897d989fe7fec9c21896cb2234bdad
|
data/README.md
CHANGED
@@ -109,6 +109,8 @@ RubyPGExtras.cache_hit
|
|
109
109
|
|
110
110
|
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.
|
111
111
|
|
112
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#cache-hit)
|
113
|
+
|
112
114
|
### `index_cache_hit`
|
113
115
|
|
114
116
|
```ruby
|
@@ -125,6 +127,8 @@ RubyPGExtras.index_cache_hit
|
|
125
127
|
|
126
128
|
The same as `cache_hit` with each table's indexes cache hit info displayed separately.
|
127
129
|
|
130
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#cache-hit)
|
131
|
+
|
128
132
|
### `table_cache_hit`
|
129
133
|
|
130
134
|
```ruby
|
@@ -141,6 +145,26 @@ RubyPGExtras.table_cache_hit
|
|
141
145
|
|
142
146
|
The same as `cache_hit` with each table's cache hit info displayed seperately.
|
143
147
|
|
148
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#cache-hit)
|
149
|
+
|
150
|
+
### `db_settings`
|
151
|
+
|
152
|
+
```ruby
|
153
|
+
|
154
|
+
RubyPGExtras.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)
|
163
|
+
|
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
|
+
|
144
168
|
### `index_usage`
|
145
169
|
|
146
170
|
```ruby
|
@@ -178,6 +202,8 @@ RubyPGExtras.locks
|
|
178
202
|
|
179
203
|
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.
|
180
204
|
|
205
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#deadlocks)
|
206
|
+
|
181
207
|
### `all_locks`
|
182
208
|
|
183
209
|
```ruby
|
@@ -210,6 +236,8 @@ This command displays statements, obtained from `pg_stat_statements`, ordered by
|
|
210
236
|
|
211
237
|
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.
|
212
238
|
|
239
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#missing-indexes)
|
240
|
+
|
213
241
|
### `calls`
|
214
242
|
|
215
243
|
```ruby
|
@@ -230,6 +258,8 @@ RubyPGExtras.calls(args: { limit: 10 })
|
|
230
258
|
|
231
259
|
This command is much like `pg:outliers`, but ordered by the number of times a statement has been called.
|
232
260
|
|
261
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#missing-indexes)
|
262
|
+
|
233
263
|
### `blocking`
|
234
264
|
|
235
265
|
```ruby
|
@@ -244,6 +274,8 @@ RubyPGExtras.blocking
|
|
244
274
|
|
245
275
|
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.
|
246
276
|
|
277
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#deadlocks)
|
278
|
+
|
247
279
|
### `total_index_size`
|
248
280
|
|
249
281
|
```ruby
|
@@ -351,6 +383,8 @@ RubyPGExtras.unused_indexes(args: { min_scans: 20 })
|
|
351
383
|
|
352
384
|
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.
|
353
385
|
|
386
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#unused-indexes)
|
387
|
+
|
354
388
|
### `null_indexes`
|
355
389
|
|
356
390
|
```ruby
|
@@ -365,7 +399,9 @@ RubyPGExtras.null_indexes(args: { min_relation_size_mb: 10 })
|
|
365
399
|
|
366
400
|
```
|
367
401
|
|
368
|
-
This
|
402
|
+
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.
|
403
|
+
|
404
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#null-indexes)
|
369
405
|
|
370
406
|
### `seq_scans`
|
371
407
|
|
@@ -389,6 +425,8 @@ RubyPGExtras.seq_scans
|
|
389
425
|
|
390
426
|
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.
|
391
427
|
|
428
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#missing-indexes)
|
429
|
+
|
392
430
|
### `long_running_queries`
|
393
431
|
|
394
432
|
```ruby
|
@@ -444,6 +482,8 @@ RubyPGExtras.bloat
|
|
444
482
|
|
445
483
|
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.
|
446
484
|
|
485
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#bloat)
|
486
|
+
|
447
487
|
### `vacuum_stats`
|
448
488
|
|
449
489
|
```ruby
|
data/lib/ruby-pg-extras.rb
CHANGED
@@ -8,7 +8,7 @@ module RubyPGExtras
|
|
8
8
|
@@database_url = nil
|
9
9
|
|
10
10
|
QUERIES = %i(
|
11
|
-
bloat blocking cache_hit
|
11
|
+
bloat blocking cache_hit db_settings
|
12
12
|
calls extensions table_cache_hit index_cache_hit
|
13
13
|
index_size index_usage null_indexes locks all_locks
|
14
14
|
long_running_queries mandelbrot outliers
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/* Values of selected PostgreSQL settings */
|
2
|
+
|
3
|
+
SELECT name, setting, unit, short_desc FROM pg_settings
|
4
|
+
WHERE name IN (
|
5
|
+
'max_connections', 'shared_buffers', 'effective_cache_size',
|
6
|
+
'maintenance_work_mem', 'checkpoint_completion_target', 'wal_buffers',
|
7
|
+
'default_statistics_target', 'random_page_cost', 'effective_io_concurrency',
|
8
|
+
'work_mem', 'min_wal_size', 'max_wal_size'
|
9
|
+
);
|
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.5.
|
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-02-
|
11
|
+
date: 2021-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- lib/ruby-pg-extras/queries/blocking.sql
|
89
89
|
- lib/ruby-pg-extras/queries/cache_hit.sql
|
90
90
|
- lib/ruby-pg-extras/queries/calls.sql
|
91
|
+
- lib/ruby-pg-extras/queries/db_settings.sql
|
91
92
|
- lib/ruby-pg-extras/queries/extensions.sql
|
92
93
|
- lib/ruby-pg-extras/queries/index_cache_hit.sql
|
93
94
|
- lib/ruby-pg-extras/queries/index_size.sql
|