Space

Database Size: <%= @database_size %>

<% if @system_stats_enabled %>
Loading...
<%= javascript_tag nonce: true do %> new Chartkick.LineChart("chart-1", <%= pghero_js_value(free_space_stats_path) %>, {colors: ["#5bc0de"], bytes: true, library: {plugins: {tooltip: {intersect: false, mode: "index"}}}}) <% end %> <% end %> <% if @unused_indexes.any? %>

<%= pluralize(@unused_indexes.size, "unused index") %>. Remove them <% if @show_migrations %> with a migration <% end %> for faster writes. <% if @database.replicating? %> Check they aren’t used on replicas. <% end %>

rails generate migration remove_unused_indexes

And paste

<% @unused_indexes.sort_by { |q| [-q[:size_bytes], q[:index]] }.each do |query| %>
<%= pghero_remove_index(query) %><% end %>
<% end %> <% if @sizes_timeout %>

Breakdown not available (system catalog locked)

<% else %> <% if @space_stats_enabled %> <% end %> <% @relation_sizes.each do |query| %> <% if @space_stats_enabled %> <% end %> <% end %>
<%= link_to (@only_tables ? "Table" : "Relation"), @header_options.merge(sort: "name") %> <%= link_to "Size", @header_options %><%= link_to "#{@days}d Growth", @header_options.merge(sort: "growth") %>
"> <% name = query[:relation] || query[:table] %> <% if @space_stats_enabled %> <%= link_to name, relation_space_path(name, schema: query[:schema]), target: "_blank", class: "relation-link" %> <% else %> <%= name %> <% end %> <% if query[:schema] != "public" %> <%= query[:schema] %> <% end %> <% if @unused_index_names.include?(query[:relation]) %> UNUSED <% end %> <%= query[:size] %> <% if @growth_bytes_by_relation[[query[:schema], query[:relation]]] %> <% if @growth_bytes_by_relation[[query[:schema], query[:relation]]] < 0 %>-<% end %><%= PgHero.pretty_size(@growth_bytes_by_relation[[query[:schema], query[:relation]]].abs) %> <% else %> Unknown <% end %>
<% end %>