Suggested Indexes
Add indexes to speed up queries.
rails generate migration add_suggested_indexes
And paste
commit_db_transaction
add_index :pghero_space_stats, [:relation, :captured_at], algorithm: :concurrently
Details
CREATE INDEX CONCURRENTLY ON pghero_space_stats (relation, captured_at)
Rows: 1772822
Row progression: 1772822, 722, 72
Row estimates
- relation (=): 722
- captured_at (>=): 177515
- database (=): 1772822
- schema (=): 1772822
Existing indexes
- id PRIMARY
- database, captured_at
to speed up
| Total Time |
Average Time |
Calls |
|
0 min
2%
|
36 ms
|
173
pghero
·
details
|
SELECT captured_at, size AS size_bytes FROM pghero_space_stats WHERE database = ? AND captured_at >= ? AND schema = ? AND relation = ? ORDER BY 1 ASC /*pghero*/
|
Slow Queries
Slow queries take 20 ms or more on average and have been called at least 100 times.
Explain queries to see where to add indexes.
| Total Time |
Average Time |
Calls |
|
0 min
3%
|
75 ms
|
180
pghero
·
details
|
SELECT n.nspname AS schema, c.relname AS relation, CASE c.relkind WHEN ? THEN ? WHEN ? then ? ELSE ? END AS type, pg_table_size(c.oid) AS size_bytes FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname NOT IN (?, ?) AND n.nspname !~ ? AND c.relkind IN (?, ?, ?) ORDER BY pg_table_size(c.oid) DESC, 2 ASC /*pghero*/
|
|
0 min
2%
|
36 ms
|
173
pghero
·
details
|
SELECT captured_at, size AS size_bytes FROM pghero_space_stats WHERE database = ? AND captured_at >= ? AND schema = ? AND relation = ? ORDER BY 1 ASC /*pghero*/
Details
CREATE INDEX CONCURRENTLY ON pghero_space_stats (relation, captured_at)
Rows: 1772822
Row progression: 1772822, 722, 72
Row estimates
- relation (=): 722
- captured_at (>=): 177515
- database (=): 1772822
- schema (=): 1772822
Existing indexes
- id PRIMARY
- database, captured_at
|