rails-pg-extras 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails-pg-extras.rb +12 -12
- data/lib/rails-pg-extras/queries/{all_locks.rb → all_locks.sql} +1 -11
- data/lib/rails-pg-extras/queries/{bloat.rb → bloat.sql} +2 -12
- data/lib/rails-pg-extras/queries/{blocking.rb → blocking.sql} +2 -12
- data/lib/rails-pg-extras/queries/{cache_hit.rb → cache_hit.sql} +1 -11
- data/lib/rails-pg-extras/queries/{calls.rb → calls.sql} +2 -12
- data/lib/rails-pg-extras/queries/extensions.sql +4 -0
- data/lib/rails-pg-extras/queries/{index_size.rb → index_size.sql} +1 -11
- data/lib/rails-pg-extras/queries/{index_usage.rb → index_usage.sql} +1 -11
- data/lib/rails-pg-extras/queries/{locks.rb → locks.sql} +1 -11
- data/lib/rails-pg-extras/queries/long_running_queries.rb +1 -11
- data/lib/rails-pg-extras/queries/{mandelbrot.rb → mandelbrot.sql} +2 -12
- data/lib/rails-pg-extras/queries/{outliers.rb → outliers.sql} +2 -12
- data/lib/rails-pg-extras/queries/records_rank.sql +9 -0
- data/lib/rails-pg-extras/queries/seq_scans.sql +7 -0
- data/lib/rails-pg-extras/queries/{table_indexes_size.rb → table_indexes_size.sql} +1 -11
- data/lib/rails-pg-extras/queries/{table_size.rb → table_size.sql} +1 -11
- data/lib/rails-pg-extras/queries/{total_index_size.rb → total_index_size.sql} +1 -11
- data/lib/rails-pg-extras/queries/{total_table_size.rb → total_table_size.sql} +1 -11
- data/lib/rails-pg-extras/queries/{unused_indexes.rb → unused_indexes.sql} +5 -15
- data/lib/rails-pg-extras/queries/{vacuum_stats.rb → vacuum_stats.sql} +2 -13
- data/lib/rails-pg-extras/version.rb +1 -1
- data/rails-pg-extras.gemspec +2 -2
- metadata +26 -25
- data/lib/rails-pg-extras/queries/extensions.rb +0 -13
- data/lib/rails-pg-extras/queries/records_rank.rb +0 -19
- data/lib/rails-pg-extras/queries/seq_scans.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6bc007ddc338613256c083afc688a962ee9e79d3430e8c725e141e26611c490
|
4
|
+
data.tar.gz: 2d27467222f23985d1ac6e463095f80de58d8bd76e7fa0089203fd5d61852f46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54a816ff465969fea4dc82ecac87ac4d98bac06b65ab138cfaa3570a23d2e099cd0dbc1ae7210d4a4fb63e44a9618c0961b41b2fcb4ccd45b61fc37cdd247baf
|
7
|
+
data.tar.gz: 34ec1ee2fd6e730983ed9be54be68b8c6603eafb93147453125567f277d327d292743f9a1cbfd95b429454c7321a54800123a5cf71cbc01a362b6c065deb1aa6
|
data/lib/rails-pg-extras.rb
CHANGED
@@ -3,19 +3,17 @@
|
|
3
3
|
require 'terminal-table'
|
4
4
|
|
5
5
|
module RailsPGExtras
|
6
|
-
QUERIES =
|
6
|
+
QUERIES = %i(
|
7
7
|
bloat blocking cache_hit
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
calls extensions
|
9
|
+
index_size index_usage locks all_locks
|
10
|
+
long_running_queries mandelbrot outliers
|
11
|
+
records_rank seq_scans table_indexes_size
|
12
|
+
table_size total_index_size total_table_size
|
13
|
+
unused_indexes vacuum_stats
|
14
14
|
)
|
15
15
|
|
16
16
|
QUERIES.each do |query_name|
|
17
|
-
require "rails-pg-extras/queries/#{query_name}"
|
18
|
-
|
19
17
|
define_singleton_method query_name do |options = { in_format: :display_table }|
|
20
18
|
run_query(
|
21
19
|
query_name: query_name,
|
@@ -25,9 +23,11 @@ module RailsPGExtras
|
|
25
23
|
end
|
26
24
|
|
27
25
|
def self.run_query(query_name:, in_format:)
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
sql_path = File.join(File.dirname(__FILE__), "/rails-pg-extras/queries/#{query_name}.sql")
|
27
|
+
sql = File.read(sql_path)
|
28
|
+
description = sql.split("\n").first[/\/\*(.*?)\*\//m, 1].strip
|
29
|
+
result = connection.execute(sql)
|
30
|
+
display_result(result, title: description, in_format: in_format)
|
31
31
|
end
|
32
32
|
|
33
33
|
def self.display_result(result, title:, in_format:)
|
@@ -1,12 +1,5 @@
|
|
1
|
-
|
1
|
+
/* Queries with active locks */
|
2
2
|
|
3
|
-
module RailsPGExtras
|
4
|
-
def self.all_locks_description
|
5
|
-
"Queries with active locks"
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.all_locks_sql
|
9
|
-
<<-EOS
|
10
3
|
SELECT
|
11
4
|
pg_stat_activity.pid,
|
12
5
|
pg_class.relname,
|
@@ -21,6 +14,3 @@ OUTER JOIN pg_class
|
|
21
14
|
WHERE pg_stat_activity.query <> '<insufficient privilege>'
|
22
15
|
AND pg_locks.pid = pg_stat_activity.pid
|
23
16
|
AND pg_stat_activity.pid <> pg_backend_pid() order by query_start;
|
24
|
-
EOS
|
25
|
-
end
|
26
|
-
end
|
@@ -1,12 +1,5 @@
|
|
1
|
-
|
1
|
+
/* Table and index bloat in your database ordered by most wasteful */
|
2
2
|
|
3
|
-
module RailsPGExtras
|
4
|
-
def self.bloat_description
|
5
|
-
"Table and index bloat in your database ordered by most wasteful"
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.bloat_sql
|
9
|
-
<<-EOS
|
10
3
|
WITH constants AS (
|
11
4
|
SELECT current_setting('block_size')::numeric AS bs, 23 AS hdr, 4 AS ma
|
12
5
|
), bloat_info AS (
|
@@ -66,8 +59,5 @@ SELECT
|
|
66
59
|
CASE WHEN ipages < iotta THEN '0' ELSE (bs*(ipages-iotta))::bigint END AS raw_waste
|
67
60
|
FROM
|
68
61
|
index_bloat) bloat_summary
|
69
|
-
ORDER BY raw_waste DESC, bloat DESC
|
70
|
-
EOS
|
71
|
-
end
|
72
|
-
end
|
62
|
+
ORDER BY raw_waste DESC, bloat DESC;
|
73
63
|
|
@@ -1,12 +1,5 @@
|
|
1
|
-
|
1
|
+
/* Queries holding locks other queries are waiting to be released */
|
2
2
|
|
3
|
-
module RailsPGExtras
|
4
|
-
def self.blocking_description
|
5
|
-
"Queries holding locks other queries are waiting to be released"
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.blocking_sql
|
9
|
-
<<-EOS
|
10
3
|
SELECT bl.pid AS blocked_pid,
|
11
4
|
ka.query AS blocking_statement,
|
12
5
|
now() - ka.query_start AS blocking_duration,
|
@@ -20,7 +13,4 @@ JOIN pg_catalog.pg_locks kl
|
|
20
13
|
JOIN pg_catalog.pg_stat_activity ka
|
21
14
|
ON kl.pid = ka.pid
|
22
15
|
ON bl.transactionid = kl.transactionid AND bl.pid != kl.pid
|
23
|
-
WHERE NOT bl.granted
|
24
|
-
EOS
|
25
|
-
end
|
26
|
-
end
|
16
|
+
WHERE NOT bl.granted;
|
@@ -1,12 +1,5 @@
|
|
1
|
-
|
1
|
+
/* Index and table hit rate */
|
2
2
|
|
3
|
-
module RailsPGExtras
|
4
|
-
def self.cache_hit_description
|
5
|
-
"Index and table hit rate"
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.cache_hit_sql
|
9
|
-
<<-EOS
|
10
3
|
SELECT
|
11
4
|
'index hit rate' AS name,
|
12
5
|
(sum(idx_blks_hit)) / nullif(sum(idx_blks_hit + idx_blks_read),0) AS ratio
|
@@ -16,6 +9,3 @@ SELECT
|
|
16
9
|
'table hit rate' AS name,
|
17
10
|
sum(heap_blks_hit) / nullif(sum(heap_blks_hit) + sum(heap_blks_read),0) AS ratio
|
18
11
|
FROM pg_statio_user_tables;
|
19
|
-
EOS
|
20
|
-
end
|
21
|
-
end
|
@@ -1,19 +1,9 @@
|
|
1
|
-
|
1
|
+
/* 10 queries that have longest execution time in aggregate */
|
2
2
|
|
3
|
-
module RailsPGExtras
|
4
|
-
def self.calls_description
|
5
|
-
"10 queries that have longest execution time in aggregate"
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.calls_sql
|
9
|
-
<<-EOS
|
10
3
|
SELECT query AS qry,
|
11
4
|
interval '1 millisecond' * total_time AS exec_time,
|
12
5
|
to_char((total_time/sum(total_time) OVER()) * 100, 'FM90D0') || '%' AS prop_exec_time,
|
13
6
|
to_char(calls, 'FM999G999G990') AS ncalls,
|
14
7
|
interval '1 millisecond' * (blk_read_time + blk_write_time) AS sync_io_time
|
15
8
|
FROM pg_stat_statements WHERE userid = (SELECT usesysid FROM pg_user WHERE usename = current_user LIMIT 1)
|
16
|
-
ORDER BY calls DESC LIMIT 10
|
17
|
-
EOS
|
18
|
-
end
|
19
|
-
end
|
9
|
+
ORDER BY calls DESC LIMIT 10;
|
@@ -1,12 +1,5 @@
|
|
1
|
-
|
1
|
+
/* The size of indexes, descending by size */
|
2
2
|
|
3
|
-
module RailsPGExtras
|
4
|
-
def self.index_size_description
|
5
|
-
"The size of indexes, descending by size"
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.index_size_sql
|
9
|
-
<<-EOS
|
10
3
|
SELECT c.relname AS name,
|
11
4
|
pg_size_pretty(sum(c.relpages::bigint*8192)::bigint) AS size
|
12
5
|
FROM pg_class c
|
@@ -16,6 +9,3 @@ AND n.nspname !~ '^pg_toast'
|
|
16
9
|
AND c.relkind='i'
|
17
10
|
GROUP BY c.relname
|
18
11
|
ORDER BY sum(c.relpages) DESC;
|
19
|
-
EOS
|
20
|
-
end
|
21
|
-
end
|
@@ -1,12 +1,5 @@
|
|
1
|
-
|
1
|
+
/* Index hit rate (effective databases are at 99% and up) */
|
2
2
|
|
3
|
-
module RailsPGExtras
|
4
|
-
def self.index_usage_description
|
5
|
-
"Index hit rate (effective databases are at 99% and up)"
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.index_usage_sql
|
9
|
-
<<-EOS
|
10
3
|
SELECT relname,
|
11
4
|
CASE idx_scan
|
12
5
|
WHEN 0 THEN 'Insufficient data'
|
@@ -17,6 +10,3 @@ SELECT relname,
|
|
17
10
|
pg_stat_user_tables
|
18
11
|
ORDER BY
|
19
12
|
n_live_tup DESC;
|
20
|
-
EOS
|
21
|
-
end
|
22
|
-
end
|
@@ -1,12 +1,5 @@
|
|
1
|
-
|
1
|
+
/* Queries with active exclusive locks */
|
2
2
|
|
3
|
-
module RailsPGExtras
|
4
|
-
def self.locks_description
|
5
|
-
"Queries with active exclusive locks"
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.locks_sql
|
9
|
-
<<-EOS
|
10
3
|
SELECT
|
11
4
|
pg_stat_activity.pid,
|
12
5
|
pg_class.relname,
|
@@ -21,6 +14,3 @@ WHERE pg_stat_activity.query <> '<insufficient privilege>'
|
|
21
14
|
AND pg_locks.pid = pg_stat_activity.pid
|
22
15
|
AND pg_locks.mode = 'ExclusiveLock'
|
23
16
|
AND pg_stat_activity.pid <> pg_backend_pid() order by query_start;
|
24
|
-
EOS
|
25
|
-
end
|
26
|
-
end
|
@@ -1,12 +1,5 @@
|
|
1
|
-
|
1
|
+
/* All queries longer than five minutes by descending duration */
|
2
2
|
|
3
|
-
module RailsPGExtras
|
4
|
-
def self.long_running_queries_description
|
5
|
-
"All queries longer than five minutes by descending duration"
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.long_running_queries_sql
|
9
|
-
<<-EOS
|
10
3
|
SELECT
|
11
4
|
pid,
|
12
5
|
now() - pg_stat_activity.query_start AS duration,
|
@@ -19,6 +12,3 @@ WHERE
|
|
19
12
|
AND now() - pg_stat_activity.query_start > interval '5 minutes'
|
20
13
|
ORDER BY
|
21
14
|
now() - pg_stat_activity.query_start DESC;
|
22
|
-
EOS
|
23
|
-
end
|
24
|
-
end
|
@@ -1,12 +1,5 @@
|
|
1
|
-
|
1
|
+
/* The mandelbrot set */
|
2
2
|
|
3
|
-
module RailsPGExtras
|
4
|
-
def self.mandelbrot_description
|
5
|
-
"The mandelbrot set"
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.mandelbrot_sql
|
9
|
-
<<-EOS
|
10
3
|
WITH RECURSIVE Z(IX, IY, CX, CY, X, Y, I) AS (
|
11
4
|
SELECT IX, IY, X::float, Y::float, X::float, Y::float, 0
|
12
5
|
FROM (select -2.2 + 0.031 * i, i from generate_series(0,101) as i) as xgen(x,ix),
|
@@ -25,7 +18,4 @@ FROM (
|
|
25
18
|
ORDER BY IY, IX
|
26
19
|
) AS ZT
|
27
20
|
GROUP BY IY
|
28
|
-
ORDER BY IY
|
29
|
-
EOS
|
30
|
-
end
|
31
|
-
end
|
21
|
+
ORDER BY IY;
|
@@ -1,12 +1,5 @@
|
|
1
|
-
|
1
|
+
/* 10 queries that have longest execution time in aggregate */
|
2
2
|
|
3
|
-
module RailsPGExtras
|
4
|
-
def self.outliers_description
|
5
|
-
"10 queries that have longest execution time in aggregate"
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.outliers_sql
|
9
|
-
<<-EOS
|
10
3
|
SELECT interval '1 millisecond' * total_time AS total_exec_time,
|
11
4
|
to_char((total_time/sum(total_time) OVER()) * 100, 'FM90D0') || '%' AS prop_exec_time,
|
12
5
|
to_char(calls, 'FM999G999G999G990') AS ncalls,
|
@@ -14,7 +7,4 @@ interval '1 millisecond' * (blk_read_time + blk_write_time) AS sync_io_time,
|
|
14
7
|
query AS query
|
15
8
|
FROM pg_stat_statements WHERE userid = (SELECT usesysid FROM pg_user WHERE usename = current_user LIMIT 1)
|
16
9
|
ORDER BY total_time DESC
|
17
|
-
LIMIT 10
|
18
|
-
EOS
|
19
|
-
end
|
20
|
-
end
|
10
|
+
LIMIT 10;
|
@@ -1,12 +1,5 @@
|
|
1
|
-
|
1
|
+
/* Total size of all the indexes on each table, descending by size */
|
2
2
|
|
3
|
-
module RailsPGExtras
|
4
|
-
def self.table_indexes_size_description
|
5
|
-
"Total size of all the indexes on each table, descending by size"
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.table_indexes_size_sql
|
9
|
-
<<-EOS
|
10
3
|
SELECT c.relname AS table,
|
11
4
|
pg_size_pretty(pg_indexes_size(c.oid)) AS index_size
|
12
5
|
FROM pg_class c
|
@@ -15,6 +8,3 @@ WHERE n.nspname NOT IN ('pg_catalog', 'information_schema')
|
|
15
8
|
AND n.nspname !~ '^pg_toast'
|
16
9
|
AND c.relkind='r'
|
17
10
|
ORDER BY pg_indexes_size(c.oid) DESC;
|
18
|
-
EOS
|
19
|
-
end
|
20
|
-
end
|
@@ -1,12 +1,5 @@
|
|
1
|
-
|
1
|
+
/* Size of the tables (excluding indexes), descending by size */
|
2
2
|
|
3
|
-
module RailsPGExtras
|
4
|
-
def self.table_size_description
|
5
|
-
"Size of the tables (excluding indexes), descending by size"
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.table_size_sql
|
9
|
-
<<-EOS
|
10
3
|
SELECT c.relname AS name,
|
11
4
|
pg_size_pretty(pg_table_size(c.oid)) AS size
|
12
5
|
FROM pg_class c
|
@@ -15,6 +8,3 @@ WHERE n.nspname NOT IN ('pg_catalog', 'information_schema')
|
|
15
8
|
AND n.nspname !~ '^pg_toast'
|
16
9
|
AND c.relkind='r'
|
17
10
|
ORDER BY pg_table_size(c.oid) DESC;
|
18
|
-
EOS
|
19
|
-
end
|
20
|
-
end
|
@@ -1,18 +1,8 @@
|
|
1
|
-
|
1
|
+
/* Total size of all indexes in MB */
|
2
2
|
|
3
|
-
module RailsPGExtras
|
4
|
-
def self.total_index_size_description
|
5
|
-
"Total size of all indexes in MB"
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.total_index_size_sql
|
9
|
-
<<-EOS
|
10
3
|
SELECT pg_size_pretty(sum(c.relpages::bigint*8192)::bigint) AS size
|
11
4
|
FROM pg_class c
|
12
5
|
LEFT JOIN pg_namespace n ON (n.oid = c.relnamespace)
|
13
6
|
WHERE n.nspname NOT IN ('pg_catalog', 'information_schema')
|
14
7
|
AND n.nspname !~ '^pg_toast'
|
15
8
|
AND c.relkind='i';
|
16
|
-
EOS
|
17
|
-
end
|
18
|
-
end
|
@@ -1,12 +1,5 @@
|
|
1
|
-
|
1
|
+
/* Size of the tables (including indexes), descending by size */
|
2
2
|
|
3
|
-
module RailsPGExtras
|
4
|
-
def self.total_table_size_description
|
5
|
-
"Size of the tables (including indexes), descending by size"
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.total_table_size_sql
|
9
|
-
<<-EOS
|
10
3
|
SELECT c.relname AS name,
|
11
4
|
pg_size_pretty(pg_total_relation_size(c.oid)) AS size
|
12
5
|
FROM pg_class c
|
@@ -15,6 +8,3 @@ WHERE n.nspname NOT IN ('pg_catalog', 'information_schema')
|
|
15
8
|
AND n.nspname !~ '^pg_toast'
|
16
9
|
AND c.relkind='r'
|
17
10
|
ORDER BY pg_total_relation_size(c.oid) DESC;
|
18
|
-
EOS
|
19
|
-
end
|
20
|
-
end
|
@@ -1,16 +1,9 @@
|
|
1
|
-
|
1
|
+
/* Unused and almost unused indexes */
|
2
|
+
/* Ordered by their size relative to the number of index scans.
|
3
|
+
Exclude indexes of very small tables (less than 5 pages),
|
4
|
+
where the planner will almost invariably select a sequential scan,
|
5
|
+
but may not in the future as the table grows */
|
2
6
|
|
3
|
-
module RailsPGExtras
|
4
|
-
def self.unused_indexes_description
|
5
|
-
"Unused and almost unused indexes"
|
6
|
-
end
|
7
|
-
# Ordered by their size relative to the number of index scans.
|
8
|
-
# Exclude indexes of very small tables (less than 5 pages),
|
9
|
-
# where the planner will almost invariably select a sequential scan,
|
10
|
-
# but may not in the future as the table grows
|
11
|
-
|
12
|
-
def self.unused_indexes_sql
|
13
|
-
<<-EOS
|
14
7
|
SELECT
|
15
8
|
schemaname || '.' || relname AS table,
|
16
9
|
indexrelname AS index,
|
@@ -21,6 +14,3 @@ JOIN pg_index i ON ui.indexrelid = i.indexrelid
|
|
21
14
|
WHERE NOT indisunique AND idx_scan < 50 AND pg_relation_size(relid) > 5 * 8192
|
22
15
|
ORDER BY pg_relation_size(i.indexrelid) / nullif(idx_scan, 0) DESC NULLS FIRST,
|
23
16
|
pg_relation_size(i.indexrelid) DESC;
|
24
|
-
EOS
|
25
|
-
end
|
26
|
-
end
|
@@ -1,12 +1,5 @@
|
|
1
|
-
|
1
|
+
/* Dead rows and whether an automatic vacuum is expected to be triggered */
|
2
2
|
|
3
|
-
module RailsPGExtras
|
4
|
-
def self.vacuum_stats_description
|
5
|
-
"Dead rows and whether an automatic vacuum is expected to be triggered"
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.vacuum_stats_sql
|
9
|
-
<<-EOS
|
10
3
|
WITH table_opts AS (
|
11
4
|
SELECT
|
12
5
|
pg_class.oid, relname, nspname, array_to_string(reloptions, '') AS relopts
|
@@ -44,8 +37,4 @@ SELECT
|
|
44
37
|
FROM
|
45
38
|
pg_stat_user_tables psut INNER JOIN pg_class ON psut.relid = pg_class.oid
|
46
39
|
INNER JOIN vacuum_settings ON pg_class.oid = vacuum_settings.oid
|
47
|
-
ORDER BY 1
|
48
|
-
EOS
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
40
|
+
ORDER BY 1;
|
data/rails-pg-extras.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.version = RailsPGExtras::VERSION
|
9
9
|
gem.authors = ["pawurb"]
|
10
10
|
gem.email = ["contact@pawelurbanek.com"]
|
11
|
-
gem.summary = %q{ Rails PostgreSQL database insights }
|
12
|
-
gem.description = %q{
|
11
|
+
gem.summary = %q{ Rails PostgreSQL performance database insights }
|
12
|
+
gem.description = %q{ Rails port of Heroku PG Extras. The goal of this project is to provide a powerful insights into PostgreSQL database for Ruby on Rails apps that are not using the default Heroku PostgreSQL plugin. }
|
13
13
|
gem.homepage = "http://github.com/pawurb/rails-pg-extras"
|
14
14
|
gem.files = `git ls-files`.split("\n")
|
15
15
|
gem.require_paths = ["lib"]
|
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.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pawurb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -38,8 +38,9 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description: "
|
42
|
-
PostgreSQL database
|
41
|
+
description: " Rails port of Heroku PG Extras. The goal of this project is to provide
|
42
|
+
a powerful insights into PostgreSQL database for Ruby on Rails apps that are not
|
43
|
+
using the default Heroku PostgreSQL plugin. "
|
43
44
|
email:
|
44
45
|
- contact@pawelurbanek.com
|
45
46
|
executables: []
|
@@ -52,26 +53,26 @@ files:
|
|
52
53
|
- README.md
|
53
54
|
- Rakefile
|
54
55
|
- lib/rails-pg-extras.rb
|
55
|
-
- lib/rails-pg-extras/queries/all_locks.
|
56
|
-
- lib/rails-pg-extras/queries/bloat.
|
57
|
-
- lib/rails-pg-extras/queries/blocking.
|
58
|
-
- lib/rails-pg-extras/queries/cache_hit.
|
59
|
-
- lib/rails-pg-extras/queries/calls.
|
60
|
-
- lib/rails-pg-extras/queries/extensions.
|
61
|
-
- lib/rails-pg-extras/queries/index_size.
|
62
|
-
- lib/rails-pg-extras/queries/index_usage.
|
63
|
-
- lib/rails-pg-extras/queries/locks.
|
56
|
+
- lib/rails-pg-extras/queries/all_locks.sql
|
57
|
+
- lib/rails-pg-extras/queries/bloat.sql
|
58
|
+
- lib/rails-pg-extras/queries/blocking.sql
|
59
|
+
- lib/rails-pg-extras/queries/cache_hit.sql
|
60
|
+
- lib/rails-pg-extras/queries/calls.sql
|
61
|
+
- lib/rails-pg-extras/queries/extensions.sql
|
62
|
+
- lib/rails-pg-extras/queries/index_size.sql
|
63
|
+
- lib/rails-pg-extras/queries/index_usage.sql
|
64
|
+
- lib/rails-pg-extras/queries/locks.sql
|
64
65
|
- lib/rails-pg-extras/queries/long_running_queries.rb
|
65
|
-
- lib/rails-pg-extras/queries/mandelbrot.
|
66
|
-
- lib/rails-pg-extras/queries/outliers.
|
67
|
-
- lib/rails-pg-extras/queries/records_rank.
|
68
|
-
- lib/rails-pg-extras/queries/seq_scans.
|
69
|
-
- lib/rails-pg-extras/queries/table_indexes_size.
|
70
|
-
- lib/rails-pg-extras/queries/table_size.
|
71
|
-
- lib/rails-pg-extras/queries/total_index_size.
|
72
|
-
- lib/rails-pg-extras/queries/total_table_size.
|
73
|
-
- lib/rails-pg-extras/queries/unused_indexes.
|
74
|
-
- lib/rails-pg-extras/queries/vacuum_stats.
|
66
|
+
- lib/rails-pg-extras/queries/mandelbrot.sql
|
67
|
+
- lib/rails-pg-extras/queries/outliers.sql
|
68
|
+
- lib/rails-pg-extras/queries/records_rank.sql
|
69
|
+
- lib/rails-pg-extras/queries/seq_scans.sql
|
70
|
+
- lib/rails-pg-extras/queries/table_indexes_size.sql
|
71
|
+
- lib/rails-pg-extras/queries/table_size.sql
|
72
|
+
- lib/rails-pg-extras/queries/total_index_size.sql
|
73
|
+
- lib/rails-pg-extras/queries/total_table_size.sql
|
74
|
+
- lib/rails-pg-extras/queries/unused_indexes.sql
|
75
|
+
- lib/rails-pg-extras/queries/vacuum_stats.sql
|
75
76
|
- lib/rails-pg-extras/railtie.rb
|
76
77
|
- lib/rails-pg-extras/tasks/all.rake
|
77
78
|
- lib/rails-pg-extras/version.rb
|
@@ -95,8 +96,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
96
|
- !ruby/object:Gem::Version
|
96
97
|
version: '0'
|
97
98
|
requirements: []
|
98
|
-
rubygems_version: 3.0.
|
99
|
+
rubygems_version: 3.0.3
|
99
100
|
signing_key:
|
100
101
|
specification_version: 4
|
101
|
-
summary: Rails PostgreSQL database insights
|
102
|
+
summary: Rails PostgreSQL performance database insights
|
102
103
|
test_files: []
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RailsPGExtras
|
4
|
-
def self.extensions_description
|
5
|
-
"Available and installed extensions"
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.extensions_sql
|
9
|
-
<<-EOS
|
10
|
-
SELECT * FROM pg_available_extensions ORDER BY installed_version;
|
11
|
-
EOS
|
12
|
-
end
|
13
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RailsPGExtras
|
4
|
-
def self.records_rank_description
|
5
|
-
"All tables and the number of rows in each ordered by number of rows descending"
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.records_rank_sql
|
9
|
-
<<-EOS
|
10
|
-
SELECT
|
11
|
-
relname AS name,
|
12
|
-
n_live_tup AS estimated_count
|
13
|
-
FROM
|
14
|
-
pg_stat_user_tables
|
15
|
-
ORDER BY
|
16
|
-
n_live_tup DESC;
|
17
|
-
EOS
|
18
|
-
end
|
19
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RailsPGExtras
|
4
|
-
def self.seq_scans_description
|
5
|
-
"Count of sequential scans by table descending by order"
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.seq_scans_sql
|
9
|
-
<<-EOS
|
10
|
-
SELECT relname AS name,
|
11
|
-
seq_scan as count
|
12
|
-
FROM
|
13
|
-
pg_stat_user_tables
|
14
|
-
ORDER BY seq_scan DESC;
|
15
|
-
EOS
|
16
|
-
end
|
17
|
-
end
|