Menu

Databricks course · Lesson 12 of 13

Databricks Monitoring, Performance and Cost: System Tables to Query Profiles

Watch and tune a Databricks platform: system tables for cost, failures and audit, alerts, the Spark UI and query profile, liquid clustering, predictive optimisation and a cost checklist.

  • Advanced
  • 7 min read
  • Updated Nov 2026
On this page
  1. Where to look
  2. Cost per job
  3. Failures and run times
  4. Audit
  5. Alerts
  6. Finding the bottleneck
  7. Table layout: clustering, partitioning and maintenance
  8. Incremental processing saves the most
  9. A cost checklist
  10. Common mistakes
  11. Interview angle
  12. Key takeaway

A Databricks platform drifts: jobs get slower as tables grow, a new source brings skew, an interactive cluster is left running, and the bill rises before anyone notices. This lesson is about seeing those changes early and fixing them in the right order: first the data layout and the query, then the compute. It assumes you know the compute options from the compute lesson and how jobs run from the Lakeflow Jobs lesson.

Where to look

Question Tool
Did last night’s job fail, and where? Job run history and the matrix view
Did a pipeline drop records or slow down? The pipeline event log
Why is this stage slow? Spark UI on classic compute; query profile on serverless and SQL warehouses
What does each job cost, which jobs fail most, who accessed what? System tables, queried with SQL
How do I hear about it before users do? Alerts and job notifications

The UI is for one job; system tables are for the whole platform. They are read-only Delta tables in the system catalog, governed by Unity Catalog, so an admin must grant access to the schemas you need. Billing records can take up to a day to appear; job records usually arrive within an hour.

Cost per job

system.billing.usage holds one row per usage record with the SKU, the quantity in DBUs and metadata such as the job ID; system.billing.list_prices holds the list price of each SKU over time. Joined, they give an approximate cost at list price:

SELECT u.usage_metadata.job_id AS job_id,
       ROUND(SUM(u.usage_quantity * p.pricing.default), 2) AS list_cost
FROM system.billing.usage AS u
JOIN system.billing.list_prices AS p
  ON u.sku_name = p.sku_name
 AND u.usage_start_time >= p.price_start_time
 AND (p.price_end_time IS NULL OR u.usage_start_time < p.price_end_time)
WHERE u.usage_date >= current_date() - INTERVAL 30 DAYS
  AND u.usage_metadata.job_id IS NOT NULL
GROUP BY ALL
ORDER BY list_cost DESC
LIMIT 20;

List price is not your negotiated price, but the ranking is what matters: the top few jobs are usually most of the spend. Tag compute and jobs (team, project, environment) so the same query can group by custom_tags for chargeback; serverless usage is attributed with serverless usage policies instead of cluster tags.

Failures and run times

system.lakeflow.job_run_timeline records job runs. Long runs are split into hourly slices, and the result state appears on the final slice, so filter on it:

SELECT job_id,
       COUNT(*) AS finished_runs,
       COUNT_IF(result_state = 'FAILED') AS failed_runs
FROM system.lakeflow.job_run_timeline
WHERE period_start_time >= current_date() - INTERVAL 7 DAYS
  AND result_state IS NOT NULL
GROUP BY job_id
ORDER BY failed_runs DESC;

Join to system.lakeflow.jobs for names and owners. The same schema has task-level and pipeline tables, so a dashboard can show failure rates and duration trends for every job without opening each one.

Audit

system.access.audit records actions across the account: who ran a query, changed a permission, downloaded results or created a token. Typical questions are “who granted access to this table?” and “which service principal read the PII schema last week?”:

SELECT event_time, user_identity.email, action_name, request_params
FROM system.access.audit
WHERE service_name = 'unityCatalog'
  AND action_name IN ('updatePermissions', 'getTable')
  AND event_date >= current_date() - INTERVAL 7 DAYS
ORDER BY event_time DESC;

Alerts

An alert runs a SQL query on a schedule and notifies people (email, Slack, Teams, webhooks) when a condition holds, for example a job’s failures in the last day above zero, dropped records in a pipeline above a threshold, or daily DBUs above a budget. Point alerts at the system-table and event-log queries above, and keep job-level failure notifications for the jobs that matter most.

Finding the bottleneck

On classic compute open the Spark UI for the slow job; on serverless and SQL warehouses open the query profile, which shows the same information per operator. Look for:

  • Skew: in a stage’s task summary, the maximum task time or shuffle read is many times the median. One key holds most of the rows. Let adaptive query execution split skewed partitions, broadcast the small side of the join, or salt the hot key.
  • Spill: tasks writing to disk because partitions do not fit in memory. Use more, smaller partitions, fix skew, or choose memory-optimised instances.
  • Large shuffles: an exchange moving most of the table. Filter and select columns earlier, pre-aggregate, or broadcast a small table.
  • Poor data skipping: the scan reads almost all files although the query filters on a column. The table’s layout does not match the filter; see the next section.
  • Too many small files: thousands of tiny files per scan slow every query. Compaction (OPTIMIZE) fixes it, and predictive optimisation runs it for you.

The partitions, shuffles and skew lesson and the adaptive query execution lesson go deeper on each.

Table layout: clustering, partitioning and maintenance

Technique What it does Use it when
Liquid clustering (CLUSTER BY) Groups data by chosen columns incrementally; keys can change without rewriting the table The default for new tables, especially large ones filtered on a few columns or with skewed values
Automatic liquid clustering (CLUSTER BY AUTO) Databricks picks and changes clustering keys from your query history Unity Catalog managed tables where you do not want to choose keys yourself
Partitioning (PARTITIONED BY) Splits data into folders by a column Very large tables with a low-cardinality column that almost every query filters on, typically a date, and each partition holding at least about a gigabyte
Z-ordering Co-locates values within files during OPTIMIZE Older tables not yet moved to liquid clustering; it cannot be combined with liquid clustering
Deletion vectors Mark deleted or updated rows instead of rewriting files Tables with frequent MERGE, UPDATE or DELETE; the rewrite happens later during maintenance

Predictive optimisation runs OPTIMIZE, VACUUM and ANALYZE automatically on Unity Catalog managed tables when Databricks predicts they help, and it is enabled by default. That is one reason to prefer managed tables: maintenance jobs and their schedules disappear. The disk cache keeps copies of remote Parquet data on the local SSDs of the workers, which speeds up repeated reads of the same data on the same compute.

The commands themselves, and how VACUUM interacts with time travel, are covered in OPTIMIZE, Z-order, VACUUM and liquid clustering.

Incremental processing saves the most

The cheapest data is data you do not reprocess. Read only new files with Auto Loader, read only changed rows with change data feed on the source table, and update targets with MERGE or streaming tables instead of rebuilding them nightly. A job that rewrites a ten-terabyte table every day to add one day of data is a design problem no cluster setting will fix.

A cost checklist

  1. Production runs on serverless or job compute, never on shared all-purpose clusters.
  2. Interactive clusters have short auto-termination and live under a compute policy.
  3. Batch jobs without tight deadlines use serverless standard performance mode.
  4. Tables are Unity Catalog managed tables with predictive optimisation and liquid clustering.
  5. Pipelines are incremental: Auto Loader, change data feed, MERGE, streaming tables.
  6. SQL users share a right-sized serverless SQL warehouse with auto-stop.
  7. Every job and cluster carries owner and project tags, and a weekly query ranks the top spenders.
  8. Alerts fire on cost spikes and failure rates, not only on individual job failures.

Common mistakes

  1. Scaling compute before reading the query profile. More nodes do not fix skew or a full scan.
  2. Partitioning by a high-cardinality column. Millions of tiny partitions make everything slower; use liquid clustering.
  3. Running maintenance jobs by hand on managed tables. Predictive optimisation already does it.
  4. Looking only at the UI. One job at a time hides the platform-wide picture that system tables show.
  5. No tags. Without owner tags, nobody can be asked about the most expensive job.

Interview angle

“Your Databricks bill doubled this month. What do you do?” Query system.billing.usage joined to list prices to find which jobs, warehouses or clusters grew. Check whether they moved to all-purpose compute, lost auto-termination, or started reprocessing full tables. Read the query profile of the worst job for skew, spill or poor data skipping, and fix the layout with liquid clustering. Then add tags, a weekly cost report and an alert so it does not happen silently again.

Key takeaway

Monitor the platform with system tables and alerts rather than job by job, and find bottlenecks in the Spark UI or query profile. Fix the data layout and incremental design before touching compute, and let Unity Catalog managed tables with liquid clustering and predictive optimisation handle routine maintenance.

By , Data Engineer and Founder of DataDank · Last reviewed Nov 2026 · Describes Databricks monitoring and optimisation features as documented in November 2026 (system tables in the system.billing, system.lakeflow and system.access schemas, predictive optimisation enabled by default for Unity Catalog managed tables). The SQL examples need a Databricks workspace with access to system tables and were checked against the documentation, not executed.

Progress is saved in this browser only. No account needed.

Search
Filter by type