Cost Control: Tags, Budgets & Billing Tables

Databricks · Architecture, Performance & Cost

Theory

Databricks bills mainly in DBUs (Databricks Units) per workload type, plus your cloud costs for classic compute and storage. To keep costs under control you need to see who uses what and stop waste. Custom tags on compute, jobs, pipelines, SQL warehouses and serverless budget policies flow into usage records, so you can split cost by team or project. The system.billing.usage table holds every usage record (date, SKU, DBUs, workspace, job or warehouse id, and custom tags), and system.billing.list_prices gives list prices to turn DBUs into money. Budgets in the account console track spending against a monthly target and email alerts when thresholds are crossed. The built-in usage dashboard gives a ready-made view.

Example: Asha tags all marketing jobs team = marketing, then a query on system.billing.usage shows the marketing team used 340 DBUs this week versus 520 for finance.

Why we use it

Cloud data platforms make it easy to leave clusters running or run expensive jobs nobody needs. Tags, billing tables and budgets turn cost into something you can measure, assign to owners and alert on before the invoice surprises anyone.

When to use it

Tag everything from day one with team, project and environment. Use auto stop and auto termination, serverless with budget policies, and job compute instead of all-purpose clusters for scheduled work. Review system.billing.usage weekly; set budgets with alerts for each team.

How it works

  1. Tag compute, jobs, warehouses and serverless policies
  2. Usage records land in system.billing.usage with tags
  3. Query or dashboard DBUs by team, product and job
  4. Is a team over its budget threshold? Yes: Budget sends an alert email. No: Keep monitoring.
  5. Fix waste: auto stop, right-size, job compute, remove idle jobs
  6. Review usage weekly

Syntax

Tags: compute/job/warehouse settings → Tags (key = value); serverless → budget policy
SQL: system.billing.usage (usage_date, sku_name, usage_quantity, usage_metadata, custom_tags, billing_origin_product)
     system.billing.list_prices (sku_name, pricing.default, price_start_time, price_end_time)
UI: account console → Usage → Budgets; usage dashboard

Example

-- DBUs per team (custom tag) in the last 7 days
SELECT custom_tags['team']   AS team,
       billing_origin_product,
       SUM(usage_quantity)   AS dbus
FROM system.billing.usage
WHERE usage_date >= current_date() - INTERVAL 7 DAYS
GROUP BY ALL
ORDER BY dbus DESC;

-- Most expensive jobs this month (by DBUs)
SELECT usage_metadata.job_id, SUM(usage_quantity) AS dbus
FROM system.billing.usage
WHERE usage_date >= date_trunc('MONTH', current_date())
  AND usage_metadata.job_id IS NOT NULL
GROUP BY usage_metadata.job_id
ORDER BY dbus DESC
LIMIT 10;

Key points

Databricks topics

Databricks Fundamentals

Compute

Notebooks & Development

Apache Spark on Databricks

Delta Lake

Unity Catalog & Governance

Data Ingestion

Declarative Pipelines (Lakeflow)

Lakeflow Jobs

Databricks SQL & BI

Architecture, Performance & Cost

Machine Learning & AI

Certification & Interview

T
Tech Town
Log InSign Up Free
Home SQL Python DSA Power BI Snowflake Databricks Spark Gen AI Practice Problems Contest Blog

Master Databricks

The lakehouse platform from the ground up: Apache Spark, Delta Lake, Unity Catalog, Lakeflow pipelines and jobs, Databricks SQL and MLflow. Click any topic in the sidebar to open it right here.

{{ sectionCount }}
Sections
{{ topicCount }}
Topics
Free
Forever
Hands-on practice Practice SQL / Spark SQL Sharpen the SQL you use in Databricks SQL and Spark SQL: 150 query problems in a live editor with instant checking. Start practising →
Section {{ sec.num }}

{{ sec.label }}

Databricks  /  {{ current.sectionLabel }}  /  {{ current.name }}

{{ current.name }}

Theory

{{ current.def }}

Why we use it

{{ rich.why }}

When to use it

{{ rich.when }}

{{ sec.h }}

{{ sec.body }}

{{ sec.body }}

Diagram

{{ rich.dg.caption }}

{{ tb.title }}
{{ c.v }}
{{ rich.dg.op }}
➜
{{ rich.dg.output.title }}
{{ c.v }}
{{ nd.label }}
{{ nd.sub }}
{{ nd.label }}
{{ nd.sub }}
{{ rich.dg.left.title }}
{{ it }}
{{ rich.dg.right.title }}
{{ it }}
On screen — where to click

{{ rich.ui.title }}

{{ u.text }}
  1. {{ st.n }}{{ st.text }}
{{ rich.ui.title }}
{{ u.text }}
Flowchart — how it works
{{ nd.text }}
{{ nd.text }}
◇ {{ nd.text }}
Yes → {{ nd.yes }}
No → {{ nd.no }}
Syntax
{{ current.syntax }}
Example
{{ current.example }}
Want to run this yourself? Databricks needs a real workspace — there's no in-browser engine for it. Click Copy above, then paste it into a notebook or the SQL editor in Databricks Free Edition (free, no credit card) and run it on serverless compute.
Key Points — click to check off as you learn
  • {{ pt.mark }} {{ pt.text }}

Share this topic