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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc0c4f898fafe14cddcbc3195d8b5b3953c0ceacfc6db3fdb5592d6c2d24d3db
4
- data.tar.gz: e55cfa4afc4a1f44146ff55f229756c3d02a1897bd21a8312aaea48defb98815
3
+ metadata.gz: '05768abc8a8d84bf67f2b5421f687044aab327521e9206cb58356d6c0905ec68'
4
+ data.tar.gz: 864923ef0192c664b46dce8ecc0b126a5d6699319fda1f101d9d36c5b1e73758
5
5
  SHA512:
6
- metadata.gz: 31d21b258ca0e7907646f44df02bf35e8805b1d45a35033b54b7a881aa1df2b7c19b1b3df8bdc396ff080f98f8b73959964d578bd00cbd218a127f372ff8a786
7
- data.tar.gz: 8b0a8653f524cf7fbbf7e6a220ce454172f1758730692ecb1b691cab3b8d559fd9525e24693989b7ccdd9d917d8dc85333bcae4f1334efa717cd4cec193fc377
6
+ metadata.gz: 113c943c72a86772077079886dc6ea0b23b82651e00dad201921b91caa40900802a5efe832f9e3945012ba23ae17c5c8044d8e18a1325ff16df965843aeb6c15
7
+ data.tar.gz: 15e13d0547b587ddb7fc3fb26bfbde451b7a9e47615631cfa379bb0fc6b69dd96a95624814e4ebec1d876861685528028b467325725815cd78d8d14a06fcdd9f
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright © Paweł Urbanek 2019
3
+ Copyright © Paweł Urbanek 2020
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
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 a powerful insights into PostgreSQL database for Ruby on Ruby apps that are not using the default Heroku PostgreSQL plugin.
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
 
@@ -0,0 +1,11 @@
1
+ version: '3'
2
+
3
+ services:
4
+ postgres:
5
+ image: postgres:11.5-alpine
6
+ environment:
7
+ POSTGRES_USER: postgres
8
+ POSTGRES_DB: ruby-pg-extras-test
9
+ POSTGRES_PASSWORD: secret
10
+ ports:
11
+ - '5432:5432'
@@ -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
@@ -1,4 +1,4 @@
1
- /* 10 queries that have longest execution time in aggregate */
1
+ /* 10 queries that have highest frequency of execution */
2
2
 
3
3
  SELECT query AS qry,
4
4
  interval '1 millisecond' * total_time AS exec_time,
@@ -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 = 'ExclusiveLock'
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;
@@ -1,3 +1,3 @@
1
1
  module RubyPGExtras
2
- VERSION = "0.6.2"
2
+ VERSION = "0.7.0"
3
3
  end
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.6.2
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-09 00:00:00.000000000 Z
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