A client asked us for its reports inside its own portal, as embedded Databricks AI/BI dashboards. It sent Power BI examples to build from. We built the first boards the fast way, rebuilding each example with AI help and giving each group of widgets its own pre-aggregated SQL. That put real data in front of the client and got the approach approved.
Then we looked at the query history. Every filter click sent the same base query to the application's database five times, once for each group of charts on a board. The user saw one answer, and the database did the work five times.
That mattered more than speed. The client's ticket said reporting must not slow the application down, and the database answering those queries was the application's own live store. The fix was one row-level query per dashboard, with the charts doing their own sums and averages.
Part 1 ended with the demo on Lakehouse Federation that these boards grew from. The setup here is an intermediate step in moving the application's reporting onto Databricks, and later parts of the series change it again.
Why the same query ran five times
An AI/BI dashboard runs each dataset as its own query, and a filter change re-runs every dataset bound to it. With five datasets per board, five copies of it reached the database every time.
One row-level dataset per dashboard
We replaced that with a rule: one row-level dataset per dashboard, with aggregation in the widgets. The dataset returns rows plus a few derived columns. Counters, bars, lines and pies compute their own SUM and AVG through the widget encoding, and the filters bind to that one dataset. The base query runs once per load and once per filter change.
What the rule costs:
- a pivot table cannot filter a shared dataset to one subset of metric rows, so each pivot keeps its own pre-aggregated query
- a counter accepts only a simple aggregate of a column, so a percentage has to be computed as a derived column in the dataset
- widgets inline the dataset SQL onto one line, so a "--" comment turns the rest of the query into a comment; we use /* */ or no comments
We made one exception. Over federation a widget cannot push its aggregation down, so the KPI counters got their own pre-aggregated dataset. Once the data moved to Delta, we folded them back into the row-level one, and the counters started cross-filtering with the charts.
Where the rule depends on the source
At production scale we saw that the rule depends on the source. Over federation, an aggregated dataset pushes its GROUP BY down to Azure SQL and returns in about 5 seconds. A raw-row dataset does not push the aggregation down and takes about 50. One wide dataset per board works well only with a fast source behind it, which is one of the reasons we later moved the data to Delta, the next step in this project's data integration after federation.
Today the combined board has 18 datasets, 15 of them bound to the filters, because pivots and per-dimension top-ten tables cannot share rows. When they run together, a dataset query takes 1.4 times longer at the median than the same query alone, and up to 3 times longer. Reducing the number of datasets further is still on our list. Like the rest of the setup, this board is one step toward the target solution on Databricks.
Next: five reports that read the same data, and what it cost to embed each one as its own dashboard.
Frequently asked questions
Where do the widgets compute their sums and averages?
That depends on the size of the dataset's result. Databricks runs filtering and aggregation in the browser for a dataset of up to 100,000 rows and 100MB, and those steps never reach the warehouse or the query history. Above that, the dashboard wraps the dataset's query in a WITH clause and aggregates on the warehouse, and it can combine visualization queries that share the same grouping and filters (dataset optimization and caching).
How many datasets can one AI/BI dashboard hold?
Up to 100 datasets per dashboard, with up to 15 pages on a canvas and 100 widgets per page (dashboard limits). Our combined board sits far below that at 18, so the limit isn't what decides the count. The cost of each extra dataset is one more query on every load and on every filter change it's bound to.
How fresh is the data on an embedded dashboard?
A dashboard keeps a 24-hour result cache to speed up its first load, so a report can show results up to a day old after the data underneath has changed. The query result cache itself never serves stale data, but the dashboard cache doesn't refresh on its own when the data changes. A dashboard schedule is the reliable way to refresh it.