rails-pg-extras 1.2.4 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -0
- data/README.md +8 -6
- data/lib/rails-pg-extras.rb +11 -5
- data/lib/rails-pg-extras/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb4905b231d556cd0a389c53a77b59e74f6d11faf45d6e3fa9e17b456cd0349a
|
4
|
+
data.tar.gz: 94e5c6c7ba1d48f403b069b5f7b7d24ae25e20f072166cf59d54fa891bf4662a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c41ba2e65e0d892690469fb232d09e58e02aa138ee17155014795963fc86a9be94d4c1d6482ca6e3564ab14a8b9263e1f7828c18ab7173cc3d0f16190ad4e12
|
7
|
+
data.tar.gz: 1aa1554a5c26f89501e59462ed4af2efc90b7d3c16b07922d71a3c7d2140096ffac47c19584edda2b4af0bc45261ea8c35f48431c94451ba86d900b51dd5a705
|
data/.circleci/config.yml
CHANGED
data/README.md
CHANGED
@@ -16,6 +16,8 @@ Alternative versions:
|
|
16
16
|
|
17
17
|
- [Python](https://github.com/pawurb/ecto_psql_extras)
|
18
18
|
|
19
|
+
- [Haskell](https://github.com/pawurb/haskell-pg-extras)
|
20
|
+
|
19
21
|
## Installation
|
20
22
|
|
21
23
|
In your Gemfile
|
@@ -106,7 +108,7 @@ $ rake pg_extras:index_cache_hit
|
|
106
108
|
(truncated results for brevity)
|
107
109
|
```
|
108
110
|
|
109
|
-
The same as `cache_hit` with each table's indexes cache hit info displayed
|
111
|
+
The same as `cache_hit` with each table's indexes cache hit info displayed separately.
|
110
112
|
|
111
113
|
### `table_cache_hit`
|
112
114
|
|
@@ -157,7 +159,7 @@ $ rake pg_extras:locks
|
|
157
159
|
(4 rows)
|
158
160
|
```
|
159
161
|
|
160
|
-
This command displays queries that have taken out an
|
162
|
+
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.
|
161
163
|
|
162
164
|
### `all_locks`
|
163
165
|
|
@@ -183,7 +185,7 @@ $ rake pg_extras:outliers
|
|
183
185
|
(truncated results for brevity)
|
184
186
|
```
|
185
187
|
|
186
|
-
This command displays statements, obtained from `pg_stat_statements`, ordered by the amount of time to execute in aggregate. This includes the statement itself, the total execution time for that statement, the proportion of total execution time for all statements that statement has taken up, the number of times that statement has been called, and the amount of time that statement spent on synchronous I/O (reading/writing from the
|
188
|
+
This command displays statements, obtained from `pg_stat_statements`, ordered by the amount of time to execute in aggregate. This includes the statement itself, the total execution time for that statement, the proportion of total execution time for all statements that statement has taken up, the number of times that statement has been called, and the amount of time that statement spent on synchronous I/O (reading/writing from the file system).
|
187
189
|
|
188
190
|
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.
|
189
191
|
|
@@ -283,7 +285,7 @@ $ rake pg_extras:table_indexes_size
|
|
283
285
|
(truncated results for brevity)
|
284
286
|
```
|
285
287
|
|
286
|
-
This command displays the total size of indexes for each table and materialized view, in MB. It is
|
288
|
+
This command displays the total size of indexes for each table and materialized view, in MB. It is calculated by using the system administration function `pg_indexes_size()`.
|
287
289
|
|
288
290
|
### `total_table_size`
|
289
291
|
|
@@ -343,7 +345,7 @@ $ rake pg_extras:seq_scans
|
|
343
345
|
(truncated results for brevity)
|
344
346
|
```
|
345
347
|
|
346
|
-
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
|
348
|
+
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.
|
347
349
|
|
348
350
|
### `long_running_queries`
|
349
351
|
|
@@ -409,7 +411,7 @@ $ rake pg_extras:vacuum_stats
|
|
409
411
|
(truncated results for brevity)
|
410
412
|
```
|
411
413
|
|
412
|
-
This command displays statistics related to vacuum operations for each table, including an
|
414
|
+
This command displays statistics related to vacuum operations for each table, including an estimation 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.
|
413
415
|
|
414
416
|
### `kill_all`
|
415
417
|
|
data/lib/rails-pg-extras.rb
CHANGED
@@ -5,20 +5,26 @@ require 'ruby-pg-extras'
|
|
5
5
|
|
6
6
|
module RailsPGExtras
|
7
7
|
QUERIES = RubyPGExtras::QUERIES
|
8
|
+
DEFAULT_ARGS = RubyPGExtras::DEFAULT_ARGS
|
8
9
|
|
9
10
|
QUERIES.each do |query_name|
|
10
|
-
define_singleton_method query_name do |options = {
|
11
|
+
define_singleton_method query_name do |options = {}|
|
11
12
|
run_query(
|
12
13
|
query_name: query_name,
|
13
|
-
in_format: options.fetch(:in_format)
|
14
|
+
in_format: options.fetch(:in_format, :display_table),
|
15
|
+
args: options.fetch(:args, {})
|
14
16
|
)
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
18
|
-
def self.run_query(query_name:, in_format:)
|
19
|
-
|
20
|
+
def self.run_query(query_name:, in_format:, args: {})
|
21
|
+
sql = if (custom_args = DEFAULT_ARGS[query_name].merge(args)) != {}
|
22
|
+
RubyPGExtras.sql_for(query_name: query_name) % custom_args
|
23
|
+
else
|
20
24
|
RubyPGExtras.sql_for(query_name: query_name)
|
21
|
-
|
25
|
+
end
|
26
|
+
|
27
|
+
result = connection.execute(sql)
|
22
28
|
|
23
29
|
RubyPGExtras.display_result(
|
24
30
|
result,
|
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.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pawurb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-22 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.
|
19
|
+
version: 1.3.0
|
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.
|
26
|
+
version: 1.3.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activerecord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
|
-
rubygems_version: 3.1.
|
111
|
+
rubygems_version: 3.1.4
|
112
112
|
signing_key:
|
113
113
|
specification_version: 4
|
114
114
|
summary: Rails PostgreSQL performance database insights
|