rails-pg-extras 0.7.0 → 1.0.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: 506d95562fb9dcf353e233962941de468492a429cf1f4c32aedbc12c8ad61ad8
4
- data.tar.gz: a26cdce454bf3a379e2cefd6219cecb3bf12aae7b9d6014b717eec9685cc98af
3
+ metadata.gz: 9b6b163cd88218757306517d2a4c25bb13c200464d41fbb4bc8c82f9831b4879
4
+ data.tar.gz: e1de0a513ba7833332f62b052d565367844d92726de14bbac7dcd75a0d7358ed
5
5
  SHA512:
6
- metadata.gz: a660057f6a220a65acf624754273fa62fe16459092b81ee5ba61c1b4a2a38f47c8204b233faf91f4a5ff9ab2bda48efdb784cc1d027f792497caba1c9c994727
7
- data.tar.gz: d2bd6dd7bae2885b36f779063e1b59ab3c402caa630f86e5d6dca83c45454c5194e3f421a532c307b06594edba4270f86c92510ee531515b053a8682427811a0
6
+ metadata.gz: c8763536e9e1ec169155f48cf962c977f095e94b203d3930d491bb997725d8ab044d3df115dc1aa5a8e97fd1afe2fa180c9ec5c9c5a1fa010655288d5a0f8ea1
7
+ data.tar.gz: ae3d6fbabded46a62bf7ca32b01efe8bb48273d27a31296a578f6ff338384626c810e2a0cc4c57076834b057e0b42e17601f030d74647eea0cb59cd50c4bc923
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Rails PG Extras [![Gem Version](https://badge.fury.io/rb/rails-pg-extras.svg)](https://badge.fury.io/rb/rails-pg-extras) [![CircleCI](https://circleci.com/gh/pawurb/rails-pg-extras.svg?style=svg)](https://circleci.com/gh/pawurb/rails-pg-extras)
2
2
 
3
- Rails 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 on Rails apps that are not using the Heroku PostgreSQL plugin.
3
+ Rails port of [Heroku PG Extras](https://github.com/heroku/heroku-pg-extras) with several additions and improvements. The goal of this project is to provide powerful insights into the PostgreSQL database for Ruby on Rails 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
 
@@ -57,8 +57,9 @@ RailsPGExtras.cache_hit(in_format: :raw) =>
57
57
 
58
58
  #### `cache_hit`
59
59
 
60
- ```bash
60
+ ```
61
61
  $ rake pg_extras:cache_hit
62
+
62
63
  name | ratio
63
64
  ----------------+------------------------
64
65
  index hit rate | 0.99957765013541945832
@@ -68,10 +69,43 @@ $ rake pg_extras:cache_hit
68
69
 
69
70
  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.
70
71
 
72
+ #### `index_cache_hit`
73
+
74
+ ```
75
+
76
+ $ rake pg_extras:index_cache_hit
77
+
78
+ | name | buffer_hits | block_reads | total_read | ratio |
79
+ +-----------------------+-------------+-------------+------------+-------------------+
80
+ | teams | 187665 | 109 | 187774 | 0.999419514948821 |
81
+ | subscriptions | 5160 | 6 | 5166 | 0.99883855981417 |
82
+ | plans | 5718 | 9 | 5727 | 0.998428496595076 |
83
+ (truncated results for brevity)
84
+ ```
85
+
86
+ The same as `cache_hit` with each table's indexes cache hit info displayed seperately.
87
+
88
+ #### `table_cache_hit`
89
+
90
+ ```
91
+
92
+ $ rake pg_extras:table_cache_hit
93
+
94
+ | name | buffer_hits | block_reads | total_read | ratio |
95
+ +-----------------------+-------------+-------------+------------+-------------------+
96
+ | plans | 32123 | 2 | 32125 | 0.999937743190662 |
97
+ | subscriptions | 95021 | 8 | 95029 | 0.999915815172211 |
98
+ | teams | 171637 | 200 | 171837 | 0.99883610631005 |
99
+ (truncated results for brevity)
100
+ ```
101
+
102
+ The same as `cache_hit` with each table's cache hit info displayed seperately.
103
+
71
104
  #### `index_usage`
72
105
 
73
106
  ```
74
107
  $ rake pg_extras:index_usage
108
+
75
109
  relname | percent_of_times_index_used | rows_in_table
76
110
  ---------------------+-----------------------------+---------------
77
111
  events | 65 | 1217347
@@ -114,6 +148,7 @@ This command displays all the current locks, regardless of their type.
114
148
 
115
149
  ```
116
150
  $ rake pg_extras:outliers
151
+
117
152
  qry | exec_time | prop_exec_time | ncalls | sync_io_time
118
153
  -----------------------------------------+------------------+----------------+-------------+--------------
119
154
  SELECT * FROM archivable_usage_events.. | 154:39:26.431466 | 72.2% | 34,211,877 | 00:00:00
@@ -122,11 +157,7 @@ $ rake pg_extras:outliers
122
157
  INSERT INTO usage_events (id, retaine.. | 01:42:59.436532 | 0.8% | 12,328,187 | 00:00:00
123
158
  SELECT * FROM usage_events WHERE (alp.. | 01:18:10.754354 | 0.6% | 102,114,301 | 00:00:00
124
159
  UPDATE usage_events SET reporter_id =.. | 00:52:35.683254 | 0.4% | 23,786,348 | 00:00:00
125
- INSERT INTO usage_events (id, retaine.. | 00:49:24.952561 | 0.4% | 21,988,201 | 00:00:00
126
- COPY public.app_ownership_events (id,.. | 00:37:14.31082 | 0.3% | 13 | 00:12:32.584754
127
- INSERT INTO app_ownership_events (id,.. | 00:26:59.808212 | 0.2% | 383,109 | 00:00:00
128
- SELECT * FROM app_ownership_events .. | 00:19:06.021846 | 0.1% | 744,879 | 00:00:00
129
- (10 rows)
160
+ (truncated results for brevity)
130
161
  ```
131
162
 
132
163
  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 filesystem).
@@ -137,6 +168,7 @@ Typically, an efficient query will have an appropriate ratio of calls to total e
137
168
 
138
169
  ```
139
170
  $ rake pg_extras:calls
171
+
140
172
  qry | exec_time | prop_exec_time | ncalls | sync_io_time
141
173
  -----------------------------------------+------------------+----------------+-------------+--------------
142
174
  SELECT * FROM usage_events WHERE (alp.. | 01:18:11.073333 | 0.6% | 102,120,780 | 00:00:00
@@ -144,12 +176,7 @@ $ rake pg_extras:calls
144
176
  COMMIT | 00:00:52.31724 | 0.0% | 47,288,615 | 00:00:00
145
177
  SELECT * FROM archivable_usage_event.. | 154:39:26.431466 | 72.2% | 34,211,877 | 00:00:00
146
178
  UPDATE usage_events SET reporter_id =.. | 00:52:35.986167 | 0.4% | 23,788,388 | 00:00:00
147
- INSERT INTO usage_events (id, retaine.. | 00:49:25.260245 | 0.4% | 21,990,326 | 00:00:00
148
- INSERT INTO usage_events (id, retaine.. | 01:42:59.436532 | 0.8% | 12,328,187 | 00:00:00
149
- SELECT * FROM app_ownership_events .. | 00:19:06.289521 | 0.1% | 744,976 | 00:00:00
150
- INSERT INTO app_ownership_events(id, .. | 00:26:59.885631 | 0.2% | 383,153 | 00:00:00
151
- UPDATE app_ownership_events SET app_i.. | 00:01:22.282337 | 0.0% | 359,741 | 00:00:00
152
- (10 rows)
179
+ (truncated results for brevity)
153
180
  ```
154
181
 
155
182
  This command is much like `pg:outliers`, but ordered by the number of times a statement has been called.
@@ -158,6 +185,7 @@ This command is much like `pg:outliers`, but ordered by the number of times a st
158
185
 
159
186
  ```
160
187
  $ rake pg_extras:blocking
188
+
161
189
  blocked_pid | blocking_statement | blocking_duration | blocking_pid | blocked_statement | blocked_duration
162
190
  -------------+--------------------------+-------------------+--------------+------------------------------------------------------------------------------------+------------------
163
191
  461 | select count(*) from app | 00:00:03.838314 | 15682 | UPDATE "app" SET "updated_at" = '2013-03-04 15:07:04.746688' WHERE "id" = 12823149 | 00:00:03.821826
@@ -170,6 +198,7 @@ This command displays statements that are currently holding locks that other sta
170
198
 
171
199
  ```
172
200
  $ rake pg_extras:total_index_size
201
+
173
202
  size
174
203
  -------
175
204
  28194 MB
@@ -194,11 +223,6 @@ $ rake pg_extras:index_size
194
223
  index_attempts_on_enrollment_id | 1957 MB
195
224
  index_enrollment_attemptables_by_enrollment_activity_id | 1789 MB
196
225
  enrollment_activities_pkey | 458 MB
197
- index_enrollment_activities_by_lesson_enrollment_and_activity | 402 MB
198
- index_placement_attempts_on_response_id | 109 MB
199
- index_placement_attempts_on_placement_test_id | 108 MB
200
- index_placement_attempts_on_grade_level_id | 97 MB
201
- index_lesson_enrollments_on_lesson_id | 93 MB
202
226
  (truncated results for brevity)
203
227
  ```
204
228
 
@@ -208,6 +232,7 @@ This command displays the size of each each index in the database, in MB. It is
208
232
 
209
233
  ```
210
234
  $ rake pg_extras:table_size
235
+
211
236
  name | size
212
237
  ---------------------------------------------------------------+---------
213
238
  learning_coaches | 196 MB
@@ -224,6 +249,7 @@ This command displays the size of each table in the database, in MB. It is calcu
224
249
 
225
250
  ```
226
251
  $ rake pg_extras:table-indexes-size
252
+
227
253
  table | indexes_size
228
254
  ---------------------------------------------------------------+--------------
229
255
  learning_coaches | 153 MB
@@ -240,6 +266,7 @@ This command displays the total size of indexes for each table, in MB. It is cal
240
266
 
241
267
  ```
242
268
  $ rake pg_extras:total_table_size
269
+
243
270
  name | size
244
271
  ---------------------------------------------------------------+---------
245
272
  learning_coaches | 349 MB
@@ -256,6 +283,7 @@ This command displays the total size of each table in the database, in MB. It is
256
283
 
257
284
  ```
258
285
  $ rake pg_extras:unused_indexes
286
+
259
287
  table | index | index_size | index_scans
260
288
  ---------------------+--------------------------------------------+------------+-------------
261
289
  public.grade_levels | index_placement_attempts_on_grade_level_id | 97 MB | 0
@@ -313,6 +341,7 @@ This command displays currently running queries, that have been running for long
313
341
 
314
342
  ```
315
343
  $ rake pg_extras:records_rank
344
+
316
345
  name | estimated_count
317
346
  -----------------------------------+-----------------
318
347
  tastypie_apiaccess | 568891
@@ -338,6 +367,7 @@ $ rake pg_extras:bloat
338
367
  index | public | bloated_table::bloated_index | 3.7 | 34 MB
339
368
  table | public | clean_table | 0.2 | 3808 kB
340
369
  table | public | other_clean_table | 0.3 | 1576 kB
370
+ (truncated results for brevity)
341
371
  ```
342
372
 
343
373
  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.
@@ -346,13 +376,14 @@ This command displays an estimation of table "bloat" – space allocated to a re
346
376
 
347
377
  ```
348
378
  $ rake pg_extras:vacuum_stats
379
+
349
380
  schema | table | last_vacuum | last_autovacuum | rowcount | dead_rowcount | autovacuum_threshold | expect_autovacuum
350
381
  --------+-----------------------+-------------+------------------+----------------+----------------+----------------------+-------------------
351
382
  public | log_table | | 2013-04-26 17:37 | 18,030 | 0 | 3,656 |
352
383
  public | data_table | | 2013-04-26 13:09 | 79 | 28 | 66 |
353
384
  public | other_table | | 2013-04-26 11:41 | 41 | 47 | 58 |
354
385
  public | queue_table | | 2013-04-26 17:39 | 12 | 8,228 | 52 | yes
355
- public | picnic_table | | | 13 | 0 | 53 |
386
+ (truncated results for brevity)
356
387
  ```
357
388
 
358
389
  This command displays statistics related to vacuum operations for each table, including an estiamtion 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.
@@ -1,3 +1,3 @@
1
1
  module RailsPGExtras
2
- VERSION = "0.7.0"
2
+ VERSION = "1.0.0"
3
3
  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: 0.7.0
4
+ version: 1.0.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 00:00:00.000000000 Z
11
+ date: 2020-01-18 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: 0.7.0
19
+ version: 1.0.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: 0.7.0
26
+ version: 1.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement