ruby-pg-extras 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +9 -9
- data/docker-compose.yml.sample +11 -0
- data/lib/ruby-pg-extras.rb +1 -3
- data/lib/ruby-pg-extras/queries/calls.sql +1 -1
- data/lib/ruby-pg-extras/queries/index_cache_hit.sql +15 -0
- data/lib/ruby-pg-extras/queries/locks.sql +2 -1
- data/lib/ruby-pg-extras/queries/table_cache_hit.sql +15 -0
- data/lib/ruby-pg-extras/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '05768abc8a8d84bf67f2b5421f687044aab327521e9206cb58356d6c0905ec68'
|
4
|
+
data.tar.gz: 864923ef0192c664b46dce8ecc0b126a5d6699319fda1f101d9d36c5b1e73758
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 113c943c72a86772077079886dc6ea0b23b82651e00dad201921b91caa40900802a5efe832f9e3945012ba23ae17c5c8044d8e18a1325ff16df965843aeb6c15
|
7
|
+
data.tar.gz: 15e13d0547b587ddb7fc3fb26bfbde451b7a9e47615631cfa379bb0fc6b69dd96a95624814e4ebec1d876861685528028b467325725815cd78d8d14a06fcdd9f
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Ruby PG Extras [![Gem Version](https://badge.fury.io/rb/ruby-pg-extras.svg)](https://badge.fury.io/rb/ruby-pg-extras) [![CircleCI](https://circleci.com/gh/pawurb/ruby-pg-extras.svg?style=svg)](https://circleci.com/gh/pawurb/ruby-pg-extras)
|
2
2
|
|
3
|
-
Ruby port of [Heroku PG Extras](https://github.com/heroku/heroku-pg-extras). The goal of this project is to provide
|
3
|
+
Ruby port of [Heroku PG Extras](https://github.com/heroku/heroku-pg-extras). The goal of this project is to provide powerful insights into the PostgreSQL database for Ruby apps that are not using the Heroku PostgreSQL plugin.
|
4
4
|
|
5
5
|
Included rake tasks and Ruby methods can be used to obtain information about a Postgres instance, that may be useful when analyzing performance issues. This includes information about locks, index usage, buffer cache hit ratios and vacuum statistics. Ruby API enables developers to easily integrate the tool into e.g. automatic monitoring tasks.
|
6
6
|
|
@@ -101,14 +101,14 @@ This command provides information on the efficiency of indexes, represented as w
|
|
101
101
|
|
102
102
|
RubyPGExtras.locks
|
103
103
|
|
104
|
-
procpid | relname | transactionid | granted | query_snippet | age
|
105
|
-
|
106
|
-
31776 | | | t | <IDLE> in transaction | 00:19:29.837898
|
107
|
-
31776 | | 1294 | t | <IDLE> in transaction | 00:19:29.837898
|
108
|
-
31912 | | | t | select * from hello; | 00:19:17.94259
|
109
|
-
3443 | | | t | +| 00:00:00
|
110
|
-
| | | | select +|
|
111
|
-
| | | | pg_stat_activi |
|
104
|
+
procpid | relname | transactionid | granted | query_snippet | mode | age
|
105
|
+
---------+---------+---------------+---------+-----------------------+-------------------------------------
|
106
|
+
31776 | | | t | <IDLE> in transaction | ExclusiveLock | 00:19:29.837898
|
107
|
+
31776 | | 1294 | t | <IDLE> in transaction | RowExclusiveLock | 00:19:29.837898
|
108
|
+
31912 | | | t | select * from hello; | ExclusiveLock | 00:19:17.94259
|
109
|
+
3443 | | | t | +| ExclusiveLock | 00:00:00
|
110
|
+
| | | | select +| |
|
111
|
+
| | | | pg_stat_activi | |
|
112
112
|
(4 rows)
|
113
113
|
```
|
114
114
|
|
data/lib/ruby-pg-extras.rb
CHANGED
@@ -9,7 +9,7 @@ module RubyPGExtras
|
|
9
9
|
|
10
10
|
QUERIES = %i(
|
11
11
|
bloat blocking cache_hit
|
12
|
-
calls extensions
|
12
|
+
calls extensions table_cache_hit index_cache_hit
|
13
13
|
index_size index_usage locks all_locks
|
14
14
|
long_running_queries mandelbrot outliers
|
15
15
|
records_rank seq_scans table_indexes_size
|
@@ -100,6 +100,4 @@ module RubyPGExtras
|
|
100
100
|
def self.database_url
|
101
101
|
@@database_url || ENV.fetch("DATABASE_URL")
|
102
102
|
end
|
103
|
-
|
104
|
-
private_class_method :connection
|
105
103
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/* Calculates your cache hit rate for reading indexes */
|
2
|
+
|
3
|
+
SELECT
|
4
|
+
relname AS name,
|
5
|
+
idx_blks_hit AS buffer_hits,
|
6
|
+
idx_blks_read AS block_reads,
|
7
|
+
idx_blks_hit + idx_blks_read AS total_read,
|
8
|
+
CASE (idx_blks_hit + idx_blks_read)::float
|
9
|
+
WHEN 0 THEN 'Insufficient data'
|
10
|
+
ELSE (idx_blks_hit / (idx_blks_hit + idx_blks_read)::float)::text
|
11
|
+
END ratio
|
12
|
+
FROM
|
13
|
+
pg_statio_user_tables
|
14
|
+
ORDER BY
|
15
|
+
idx_blks_hit / (idx_blks_hit + idx_blks_read + 1)::float DESC;
|
@@ -5,6 +5,7 @@ SELECT
|
|
5
5
|
pg_class.relname,
|
6
6
|
pg_locks.transactionid,
|
7
7
|
pg_locks.granted,
|
8
|
+
pg_locks.mode,
|
8
9
|
pg_stat_activity.query AS query_snippet,
|
9
10
|
age(now(),pg_stat_activity.query_start) AS "age"
|
10
11
|
FROM pg_stat_activity,pg_locks left
|
@@ -12,5 +13,5 @@ OUTER JOIN pg_class
|
|
12
13
|
ON (pg_locks.relation = pg_class.oid)
|
13
14
|
WHERE pg_stat_activity.query <> '<insufficient privilege>'
|
14
15
|
AND pg_locks.pid = pg_stat_activity.pid
|
15
|
-
AND pg_locks.mode
|
16
|
+
AND pg_locks.mode IN ('ExclusiveLock', 'AccessExclusiveLock', 'RowExclusiveLock')
|
16
17
|
AND pg_stat_activity.pid <> pg_backend_pid() order by query_start;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/* Calculates your cache hit rate for reading tables */
|
2
|
+
|
3
|
+
SELECT
|
4
|
+
relname AS name,
|
5
|
+
heap_blks_hit AS buffer_hits,
|
6
|
+
heap_blks_read AS block_reads,
|
7
|
+
heap_blks_hit + heap_blks_read AS total_read,
|
8
|
+
CASE (heap_blks_hit + heap_blks_read)::float
|
9
|
+
WHEN 0 THEN 'Insufficient data'
|
10
|
+
ELSE (heap_blks_hit / (heap_blks_hit + heap_blks_read)::float)::text
|
11
|
+
END ratio
|
12
|
+
FROM
|
13
|
+
pg_statio_user_tables
|
14
|
+
ORDER BY
|
15
|
+
heap_blks_hit / (heap_blks_hit + heap_blks_read + 1)::float DESC;
|
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: 0.
|
4
|
+
version: 0.7.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-01-
|
11
|
+
date: 2020-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- LICENSE.txt
|
82
82
|
- README.md
|
83
83
|
- Rakefile
|
84
|
+
- docker-compose.yml.sample
|
84
85
|
- lib/ruby-pg-extras.rb
|
85
86
|
- lib/ruby-pg-extras/queries/all_locks.sql
|
86
87
|
- lib/ruby-pg-extras/queries/bloat.sql
|
@@ -88,6 +89,7 @@ files:
|
|
88
89
|
- lib/ruby-pg-extras/queries/cache_hit.sql
|
89
90
|
- lib/ruby-pg-extras/queries/calls.sql
|
90
91
|
- lib/ruby-pg-extras/queries/extensions.sql
|
92
|
+
- lib/ruby-pg-extras/queries/index_cache_hit.sql
|
91
93
|
- lib/ruby-pg-extras/queries/index_size.sql
|
92
94
|
- lib/ruby-pg-extras/queries/index_usage.sql
|
93
95
|
- lib/ruby-pg-extras/queries/locks.sql
|
@@ -96,6 +98,7 @@ files:
|
|
96
98
|
- lib/ruby-pg-extras/queries/outliers.sql
|
97
99
|
- lib/ruby-pg-extras/queries/records_rank.sql
|
98
100
|
- lib/ruby-pg-extras/queries/seq_scans.sql
|
101
|
+
- lib/ruby-pg-extras/queries/table_cache_hit.sql
|
99
102
|
- lib/ruby-pg-extras/queries/table_indexes_size.sql
|
100
103
|
- lib/ruby-pg-extras/queries/table_size.sql
|
101
104
|
- lib/ruby-pg-extras/queries/total_index_size.sql
|