{# Storage Billing recommendations — dataset-level LOGICAL→PHYSICAL switches surfaced from the ``storage_billing_optimization`` rule. Each card shows the savings, current vs. proposed cost, a per-table breakdown, and a copyable ALTER SCHEMA snippet. #} {% extends "layout.html" %} {% block content %}

Storage Billing

Datasets currently on LOGICAL billing where switching to PHYSICAL would reduce monthly storage cost. Each card shows the dataset-level savings and a ready-to-run ALTER SCHEMA statement.

{% if not recommendations %}

No storage billing recommendations

Either every dataset is already on PHYSICAL billing, or the projected savings sit below the materiality threshold (~$10/month). Re-run a scan after data growth to re-check.

{% else %} {# Roll-up strip — total opportunity across all flagged datasets. #}

Datasets flagged

{{ recommendations | length }}

Total monthly savings

${{ '%.2f' | format(total_monthly_savings) }}

Total annual savings

${{ '%.2f' | format(total_annual_savings) }}

{% for rec in recommendations %}
{# Header row: dataset + savings pill. #}

{{ rec.affected_table }}

{{ rec.table_count }} table{{ '' if rec.table_count == 1 else 's' }} · {{ '%.1f' | format(rec.compression_ratio) }}:1 compression

Monthly saving

${{ '%.2f' | format(rec.monthly_savings) }}

{{ '%.1f' | format(rec.savings_percentage) }}% reduction

{# Cost comparison strip. #}

Current (logical)

${{ '%.2f' | format(rec.logical_cost_monthly) }}/mo

After switch (physical)

${{ '%.2f' | format(rec.physical_cost_monthly) }}/mo

Logical bytes

{{ '%.2f' | format(rec.total_logical_gb) }} GB

Physical bytes

{{ '%.2f' | format(rec.total_physical_gb) }} GB

{# ALTER SCHEMA snippet — the actionable bit. #}

Apply

ALTER SCHEMA `{{ rec.affected_table }}` SET OPTIONS (storage_billing_model = 'PHYSICAL');
{# Per-table breakdown — collapsed by default to keep the card scannable. Tables with no savings still show so the user can see the full dataset shape. #} {% if rec.tables %}
Show per-table breakdown ({{ rec.tables | length }} table{{ '' if rec.tables|length == 1 else 's' }})
{% for t in rec.tables %} {% endfor %}
Table Logical GB Physical GB Compression Monthly saving
{{ t.table_name }} {{ '%.2f' | format(t.total_logical_gb) }} {{ '%.2f' | format(t.total_physical_gb) }} {{ '%.1f' | format(t.compression_ratio) }}:1 ${{ '%.2f' | format(t.monthly_savings) }}
{% endif %}
{% endfor %}
{% endif %}
{% endblock %}