Why this matters
As a BI Analyst, you will decide whether dashboards query data live or use cached/extracted data. The right choice keeps dashboards fast, affordable, and fresh enough for stakeholders. Typical tasks you will face:
- Designing a KPI dashboard that loads under 3 seconds during peak hours.
- Balancing near real-time visibility for operations with warehouse cost limits.
- Scheduling extracts with incremental refresh to reduce load on source systems.
- Setting cache time-to-live (TTL) to control staleness vs. speed.
- Avoiding performance regressions when concurrency grows.
Concept explained simply
There are two broad ways to power a BI view:
- Live: Each dashboard action sends a query to the source system (e.g., warehouse). Freshness is highest, but cost and latency can grow with traffic.
- Extract/Cache: Data is periodically copied, aggregated, or cached. Views are much faster and cheaper to run, but data can be minutes/hours old.
Plain-language definitions
- Cache: A short-term memory of previous query results to speed up repeat requests.
- Extract: A snapshot of data taken on a schedule, often with incremental updates.
- TTL (Time-to-Live): How long a cached result is considered valid before it is recomputed.
- Staleness budget: The maximum acceptable delay between the latest data and what the dashboard shows (e.g., 15 minutes, 2 hours, 1 day).
Mental model: Freshness–Speed–Cost triangle
You can usually optimize two of the three:
- Freshness: Live queries or very short cache TTL.
- Speed: Extracts, pre-aggregations, and longer TTL.
- Cost: Caching and extracts reduce compute against source systems.
Decide by setting explicit targets: latency (e.g., <3s), staleness budget (e.g., <15m), and cost cap (e.g., daily credits).
Decision framework (fast checklist)
- Define staleness budget: How old can data be and still be useful? (e.g., 5m, 15m, 1h, 1d)
- Set performance target: Page should load in X seconds at Y concurrent users.
- Check source load sensitivity: Is the warehouse or operational DB OK with many queries?
- Estimate data volume and complexity: Big joins and billions of rows favor extracts/pre-aggregations.
- Consider security: Row-level security and user-specific data may reduce cache hit rates.
- Decide:
- If staleness budget is strict (near 0), prefer Live with optimizations (materialized views, aggregates).
- If staleness budget is flexible, prefer Extract/Cache with incremental refresh.
Pro tips for each option
- Live: Use pre-aggregations/materialized views, limit high-cardinality dimensions, add selective filters and indexing at the source.
- Extract/Cache: Use incremental keys (e.g., updated_at), schedule refresh based on staleness budget, define TTL, warm key queries after refresh.
Worked examples
Example 1: Executive KPIs (daily)
- Need: Loads <2s, data can be up to 24h old.
- Traffic: Moderate.
- Decision: Extract with daily full refresh + small incremental for late-arriving rows.
- Extras: Cache TTL 12h; pre-aggregate to daily grain.
Example 2: Support queue monitoring (near real-time)
- Need: <5m staleness, <3s load, high concurrency during business hours.
- Decision: Hybrid: Live against a fast pre-aggregated table updated every 2–3 minutes.
- Extras: Short cache TTL (1–2m) to absorb bursts; limit drill-down to recent period.
Example 3: Product analytics with large history
- Need: Analysts explore 2B+ events; staleness budget 1–6h.
- Decision: Extract partitioned by date, incremental based on event_date and updated_at.
- Extras: Pre-aggregate to session/day; cache top queries for 4h.
Example 4: Finance cutoff dashboard
- Need: During monthly close, data must be exact as of cutoff; later it should not change without an intentional refresh.
- Decision: Extract snapshot at cutoff; disable auto-refresh until the close is done.
- Extras: Show "As of" timestamp at top of dashboard.
How caching works (practical)
- Query result cache: Stores results for identical queries and parameters. Great for repeated views; may be bypassed by user-specific filters.
- Data extracts: Stored data files/tables refreshed on schedule. Fast and stable performance; data is as fresh as last refresh.
- Pre-aggregations/materialized views: Precomputed tables that speed up both live and extracted approaches.
Cache hygiene: warming and busting
- Warm cache after refresh by loading popular views/filters.
- Bust cache when a critical correction is made so users see updates immediately.
- Choose TTL to match staleness budget; shorter TTL increases freshness but reduces cache hit rate.
Configuration recipes (generic)
- Define staleness budget: e.g., 15 minutes.
- Pick mode: If budget <= 5 minutes, consider Live + pre-aggregations; else Extract/Cache.
- Set refresh: Incremental on updated_at; schedule every 15 minutes.
- Set TTL: Query cache TTL 10–15 minutes to align with refresh.
- Pre-aggregate: Create daily/ hourly summary tables for heavy dashboards.
- RLS note: If row-level security is per user, cache at group-level where safe to improve hit rates.
Exercises you can do now
Note: The quick test is available to everyone; only logged-in users will have their progress saved.
Exercise 1: Choose the right mode
Your sales dashboard has:
- Staleness budget: 30 minutes
- Users: 60 concurrent during peak
- Data: 200M rows, wide fact table, joins to 6 dims
- Source sensitivity: Warehouse credits are limited at peak
Decide: Live or Extract/Cache? Propose refresh schedule, TTL, and any pre-aggregations.
Exercise 2: Tune a slow live dashboard
A live operations page loads in 12 seconds. Requirements: <3 seconds, data <= 2 minutes old, heavy filtering by region and product.
Propose changes to meet the targets without overloading the source.
Self-check checklist
- Did you align TTL with staleness budget?
- Did you propose incremental refresh with stable keys?
- Did you limit high-cardinality dimensions in the hottest queries?
- Did you consider pre-aggregations/materialized views?
- Did you protect the source from burst traffic?
Common mistakes and how to self-check
- Undefined freshness target: Always write a staleness budget (e.g., "<= 15m").
- Overusing live when data could be 30–60m old; costs soar and pages slow.
- Overusing extracts for near-real-time needs; users lose trust.
- No incremental refresh: Full refreshes are slow and expensive.
- Ignoring RLS effects: User-specific filters reduce cache reuse; consider group-level caching where policy allows.
- Mismatched TTL and refresh: TTL longer than refresh hides updates; TTL much shorter than refresh wastes cache.
Quick self-audit
- Document: latency target, staleness budget, concurrency, cost cap.
- Verify: pre-aggregations exist for top 5 dashboards.
- Confirm: refresh logs show incremental updates within expected time.
- Check: dashboard displays "Data as of" timestamp.
Practical projects
- Project 1: Convert a slow live dashboard to an extract-based version with incremental refresh and a 30-minute TTL. Measure load time, cost, and cache hit rate before/after.
- Project 2: Build a near real-time monitoring view using live queries against a pre-aggregated table that updates every 2 minutes. Add a short TTL and simulate 50 concurrent users.
Who this is for
- BI Analysts, Data Analysts, and Analytics Engineers responsible for dashboard performance and reliability.
Prerequisites
- Basic SQL (joins, filters, aggregations).
- Familiarity with BI dashboards and data refresh concepts.
- Understanding of row-level security basics.
Learning path
- Caching and Extract vs Live decisions (this lesson).
- Pre-aggregations and materialized views.
- Concurrency planning and cost controls.
- Monitoring refresh health and cache hit rates.
Next steps
- Apply the decision framework to one of your dashboards this week.
- Document the chosen mode, staleness budget, TTL, and refresh plan.
- Run the quick test to reinforce key concepts.
Mini challenge (5 minutes)
Design for a marketing dashboard with hourly KPI updates, 100 concurrent viewers, cost-sensitive warehouse, and tolerance of 30–60 minutes staleness. Write a 3-line plan: mode, refresh, TTL, and one pre-aggregation.