rails-pg-extras 1.1.0 → 1.2.4

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: 780e5bd6ea4fb796ff83e4e249ac603ae7a74bf4a11d6e7414a72f82a433926c
4
- data.tar.gz: 3499bfe705e3bcde82fa4b6417cbd275d3c9cbea6f57b03db384a3b370323020
3
+ metadata.gz: 808e77df9b7f529b420f7a88775e90e031b055dd26804fd61a80b6fc2e8d96b7
4
+ data.tar.gz: '01853117599237d182f2edb901550cf52ba46691a98e1f8a1f2594f139b90e4b'
5
5
  SHA512:
6
- metadata.gz: a790f7359529dc48fce3ae4632742565a0de41b4d9463c419a1cd676361a40fed66f26e84e0d19611f466b533f67927813747a05d5e2d517b348e6be04bc5843
7
- data.tar.gz: 5bb4bf5375df56cb3a48338e6e785cc9dd11d9859ab7c6290e5367c84b390f8c4433131920854f8fcc188df20f1bf55542c807d15a3bb3eee32d62a9888ec652
6
+ metadata.gz: e2d7d8a9558dea4637026b9c165942816c77527229172ca398c81ee0badc940e0c970f4049b2464d2aa667cef83ec43f11d8afd0c253203fda98b47f6703e87f
7
+ data.tar.gz: 7f4975baacf9d2822eeca20f260f03debec3dabb1e11544c48bf4b0a323393c8966a792b64e91777e95758c29cc69a1295660174195ddb66310c9601fd66d148
data/README.md CHANGED
@@ -4,7 +4,17 @@ Rails port of [Heroku PG Extras](https://github.com/heroku/heroku-pg-extras) wit
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
 
7
- Not using Rails? Check out the core dependency [pure Ruby version](https://github.com/pawurb/ruby-pg-extras).
7
+ You can check out this blog post for detailed step by step tutorial on how to [optimize PostgreSQL using PG Extras library](https://pawelurbanek.com/postgresql-fix-performance).
8
+
9
+ Alternative versions:
10
+
11
+ - Core dependency - [Ruby](https://github.com/pawurb/ruby-pg-extras)
12
+
13
+ - [NodeJS](https://github.com/pawurb/node-postgres-extras)
14
+
15
+ - [Elixir](https://github.com/pawurb/ecto_psql_extras)
16
+
17
+ - [Python](https://github.com/pawurb/ecto_psql_extras)
8
18
 
9
19
  ## Installation
10
20
 
@@ -14,6 +24,19 @@ In your Gemfile
14
24
  gem "rails-pg-extras"
15
25
  ```
16
26
 
27
+ Some of the queries (e.g., `calls` and `outliers`) require [pg_stat_statements](https://www.postgresql.org/docs/current/pgstatstatements.html) extension enabled.
28
+
29
+ You can check if it is enabled in your database by running:
30
+
31
+ ```ruby
32
+ RailsPGExtras.extensions
33
+ ```
34
+ You should see the similar line in the output:
35
+
36
+ ```bash
37
+ | pg_stat_statements | 1.7 | 1.7 | track execution statistics of all SQL statements executed |
38
+ ```
39
+
17
40
  ## Usage
18
41
 
19
42
  Each command can be used as a rake task, or a directly from the Ruby code.
@@ -243,12 +266,12 @@ $ rake pg_extras:table_size
243
266
  (truncated results for brevity)
244
267
  ```
245
268
 
246
- This command displays the size of each table in the database, in MB. It is calculated by using the system administration function `pg_table_size()`, which includes the size of the main data fork, free space map, visibility map and TOAST data.
269
+ This command displays the size of each table and materialized view in the database, in MB. It is calculated by using the system administration function `pg_table_size()`, which includes the size of the main data fork, free space map, visibility map and TOAST data.
247
270
 
248
271
  ### `table_indexes_size`
249
272
 
250
273
  ```
251
- $ rake pg_extras:table-indexes-size
274
+ $ rake pg_extras:table_indexes_size
252
275
 
253
276
  table | indexes_size
254
277
  ---------------------------------------------------------------+--------------
@@ -260,7 +283,7 @@ $ rake pg_extras:table-indexes-size
260
283
  (truncated results for brevity)
261
284
  ```
262
285
 
263
- This command displays the total size of indexes for each table, in MB. It is calcualtes by using the system administration function `pg_indexes_size()`.
286
+ This command displays the total size of indexes for each table and materialized view, in MB. It is calcualtes by using the system administration function `pg_indexes_size()`.
264
287
 
265
288
  ### `total_table_size`
266
289
 
@@ -277,7 +300,7 @@ $ rake pg_extras:total_table_size
277
300
  (truncated results for brevity)
278
301
  ```
279
302
 
280
- This command displays the total size of each table in the database, in MB. It is calculated by using the system administration function `pg_total_relation_size()`, which includes table size, total index size and TOAST data.
303
+ This command displays the total size of each table and materialized view in the database, in MB. It is calculated by using the system administration function `pg_total_relation_size()`, which includes table size, total index size and TOAST data.
281
304
 
282
305
  ### `unused_indexes`
283
306
 
@@ -398,6 +421,16 @@ RailsPGExtras.kill_all
398
421
 
399
422
  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.
400
423
 
424
+ ### `extensions`
425
+
426
+ ```ruby
427
+
428
+ RailsPGExtras.extensions
429
+
430
+ ```
431
+
432
+ This command lists all the currently installed and available PostgreSQL extensions.
433
+
401
434
  ### mandelbrot
402
435
 
403
436
  ```
@@ -405,9 +438,3 @@ $ rake pg_extras:mandelbrot
405
438
  ```
406
439
 
407
440
  This command outputs the Mandelbrot set, calculated through SQL.
408
-
409
- ## FAQ
410
-
411
- * Does is not violate the Heroku PG Extras license?
412
-
413
- The original plugin is MIT based so it means that copying and redistribution in any format is permitted.
@@ -3,9 +3,19 @@
3
3
  require 'rails-pg-extras'
4
4
 
5
5
  namespace :pg_extras do
6
+ task :establish_connection do
7
+ if ENV['DATABASE_URL'].present?
8
+ ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
9
+ else
10
+ db_config_file = File.read('config/database.yml')
11
+ db_config = YAML::load(ERB.new(db_config_file).result)
12
+ ActiveRecord::Base.establish_connection(db_config[Rails.env])
13
+ end
14
+ end
15
+
6
16
  RailsPGExtras::QUERIES.each do |query_name|
7
17
  desc RubyPGExtras.description_for(query_name: query_name)
8
- task query_name.to_sym => :environment do
18
+ task query_name.to_sym => :establish_connection do
9
19
  RailsPGExtras.public_send(query_name)
10
20
  end
11
21
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsPGExtras
2
- VERSION = "1.1.0"
4
+ VERSION = "1.2.4"
3
5
  end
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.1.0
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawurb
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-23 00:00:00.000000000 Z
11
+ date: 2020-10-13 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.1.0
19
+ version: 1.2.4
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.1.0
26
+ version: 1.2.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -93,7 +93,7 @@ homepage: http://github.com/pawurb/rails-pg-extras
93
93
  licenses:
94
94
  - MIT
95
95
  metadata: {}
96
- post_install_message:
96
+ post_install_message:
97
97
  rdoc_options: []
98
98
  require_paths:
99
99
  - lib
@@ -108,8 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  requirements: []
111
- rubygems_version: 3.0.6
112
- signing_key:
111
+ rubygems_version: 3.1.2
112
+ signing_key:
113
113
  specification_version: 4
114
114
  summary: Rails PostgreSQL performance database insights
115
115
  test_files: