Skip to content

Commit

Permalink
Revert "Added option for materialized views"
Browse files Browse the repository at this point in the history
This reverts commit 9074310.
  • Loading branch information
ankane committed May 4, 2024
1 parent 78a5f70 commit 47628a0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/controllers/pg_hero/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def space
@days = (params[:days] || 7).to_i
@database_size = @database.database_size
@only_tables = params[:tables].present?
@relation_sizes, @sizes_timeout = rescue_timeout([]) { @only_tables ? @database.table_sizes : @database.relation_sizes(matviews: true) }
@relation_sizes, @sizes_timeout = rescue_timeout([]) { @only_tables ? @database.table_sizes : @database.relation_sizes }
@space_stats_enabled = @database.space_stats_enabled? && !@only_tables
if @space_stats_enabled
space_growth = @database.space_growth(days: @days, relation_sizes: @relation_sizes)
Expand Down
4 changes: 2 additions & 2 deletions lib/pghero/methods/space.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def database_size
PgHero.pretty_size select_one("SELECT pg_database_size(current_database())")
end

def relation_sizes(matviews: false)
def relation_sizes
select_all_size <<~SQL
SELECT
n.nspname AS schema,
Expand All @@ -19,7 +19,7 @@ def relation_sizes(matviews: false)
WHERE
n.nspname NOT IN ('pg_catalog', 'information_schema')
AND n.nspname !~ '^pg_toast'
AND c.relkind IN ('r', 'i'#{matviews ? ", 'm'" : ""})
AND c.relkind IN ('r', 'm', 'i')
ORDER BY
pg_table_size(c.oid) DESC,
2 ASC
Expand Down
7 changes: 0 additions & 7 deletions test/space_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ def test_relation_sizes
relation_sizes = database.relation_sizes
assert relation_sizes.find { |r| r[:relation] == "users" && r[:type] == "table" }
assert relation_sizes.find { |r| r[:relation] == "users_pkey" && r[:type] == "index" }
refute relation_sizes.find { |r| r[:relation] == "all_users" && r[:type] == "matview" }
end

def test_relation_sizes_matviews
relation_sizes = database.relation_sizes(matviews: true)
assert relation_sizes.find { |r| r[:relation] == "users" && r[:type] == "table" }
assert relation_sizes.find { |r| r[:relation] == "users_pkey" && r[:type] == "index" }
assert relation_sizes.find { |r| r[:relation] == "all_users" && r[:type] == "matview" }
end

Expand Down

0 comments on commit 47628a0

Please sign in to comment.