ruby-pg-extras 1.5.3 → 1.6.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 517f1d39dfe5d78d1e8f7650767664b9bc349bf062efb60b421e568afe65be82
|
4
|
+
data.tar.gz: b60152d78952c4dc8bcee791d445d1aa0028d60bb0af47736095c5b587f605bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d827609746ab9a203a80c40945ca4b394d9014443d3fb89ae938734d996e3dc3e7f9bce584a7d98297a490365b76e8209e3d43501f932c9c7d39078891f77d4
|
7
|
+
data.tar.gz: 95dd7b3bb562e194ddac894b9f1e66d05d37d933561333a127ae9dca649c0e2b2259a46b518117b06bcce72729574250b46be935e3f2245eaf9c812ed48346ad
|
data/README.md
CHANGED
@@ -165,6 +165,8 @@ RubyPGExtras.db_settings
|
|
165
165
|
|
166
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
167
|
|
168
|
+
[More info](https://pawelurbanek.com/postgresql-fix-performance#cache-hit)
|
169
|
+
|
168
170
|
### `index_usage`
|
169
171
|
|
170
172
|
```ruby
|
@@ -531,3 +533,19 @@ RubyPGExtras.mandelbrot
|
|
531
533
|
```
|
532
534
|
|
533
535
|
This command outputs the Mandelbrot set, calculated through SQL.
|
536
|
+
|
537
|
+
### `buffercache_stats`
|
538
|
+
|
539
|
+
This command shows the relations buffered in database share buffer, ordered by percentage taken. It also shows that how much of the whole relation is buffered.
|
540
|
+
|
541
|
+
```ruby
|
542
|
+
RubyPGExtras.buffercache_stats(args: { limit: 10 })
|
543
|
+
```
|
544
|
+
|
545
|
+
### `buffercache_usage`
|
546
|
+
|
547
|
+
This command calculates how many blocks from which table are currently cached.
|
548
|
+
|
549
|
+
```ruby
|
550
|
+
RubyPGExtras.buffercache_usage(args: { limit: 20 })
|
551
|
+
```
|
data/lib/ruby-pg-extras.rb
CHANGED
@@ -15,12 +15,15 @@ module RubyPGExtras
|
|
15
15
|
records_rank seq_scans table_indexes_size
|
16
16
|
table_size total_index_size total_table_size
|
17
17
|
unused_indexes vacuum_stats kill_all
|
18
|
+
buffercache_stats buffercache_usage
|
18
19
|
)
|
19
20
|
|
20
21
|
DEFAULT_ARGS = Hash.new({}).merge({
|
21
22
|
calls: { limit: 10 },
|
22
23
|
long_running_queries: { threshold: "500 milliseconds" },
|
23
24
|
outliers: { limit: 10 },
|
25
|
+
buffercache_stats: { limit: 10 },
|
26
|
+
buffercache_usage: { limit: 20 },
|
24
27
|
unused_indexes: { min_scans: 50 },
|
25
28
|
null_indexes: { min_relation_size_mb: 10 }
|
26
29
|
})
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/* Calculates percentages of relations buffered in database share buffer */
|
2
|
+
|
3
|
+
SELECT
|
4
|
+
c.relname,
|
5
|
+
pg_size_pretty(count(*) * 8192) AS buffered,
|
6
|
+
round(100.0 * count(*) / (SELECT setting FROM pg_settings WHERE name = 'shared_buffers')::integer, 1) AS buffer_percent,
|
7
|
+
round(100.0 * count(*) * 8192 / pg_table_size(c.oid), 1) AS percent_of_relation
|
8
|
+
FROM pg_class c
|
9
|
+
INNER JOIN pg_buffercache b ON b.relfilenode = c.relfilenode
|
10
|
+
INNER JOIN pg_database d ON (b.reldatabase = d.oid AND d.datname = current_database())
|
11
|
+
GROUP BY c.oid,c.relname
|
12
|
+
ORDER BY 3 DESC
|
13
|
+
LIMIT %{limit};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/* Calculate how many blocks from which table are currently cached */
|
2
|
+
|
3
|
+
SELECT c.relname, count(*) AS buffers
|
4
|
+
FROM pg_class c
|
5
|
+
INNER JOIN pg_buffercache b ON b.relfilenode = c.relfilenode
|
6
|
+
INNER JOIN pg_database d ON (b.reldatabase = d.oid AND d.datname = current_database())
|
7
|
+
GROUP BY c.relname
|
8
|
+
ORDER BY 2 DESC
|
9
|
+
LIMIT %{limit};
|
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.6.0
|
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-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -86,6 +86,8 @@ files:
|
|
86
86
|
- lib/ruby-pg-extras/queries/all_locks.sql
|
87
87
|
- lib/ruby-pg-extras/queries/bloat.sql
|
88
88
|
- lib/ruby-pg-extras/queries/blocking.sql
|
89
|
+
- lib/ruby-pg-extras/queries/buffercache_stats.sql
|
90
|
+
- lib/ruby-pg-extras/queries/buffercache_usage.sql
|
89
91
|
- lib/ruby-pg-extras/queries/cache_hit.sql
|
90
92
|
- lib/ruby-pg-extras/queries/calls.sql
|
91
93
|
- lib/ruby-pg-extras/queries/db_settings.sql
|