Skip to content

Materialized Views

Feature ID: Materialized Views Status: Production-Ready Last Updated: January 4, 2026


Overview

HeliosDB's materialized views provide automatic query optimization through pre-computed result caching with intelligent refresh strategies and transparent query rewriting. Materialized views significantly accelerate read-heavy workloads by storing pre-computed query results that are automatically kept up-to-date.

Key Capabilities

Capability Description Benefit
Incremental Refresh Update only changed data 10-100x faster refresh
Flexible Scheduling Manual, on-commit, interval, cron Match any workload pattern
Query Rewriting Automatic view substitution Transparent optimization
Multiple Storage Backends LSM, Memory, Columnar, Hybrid Optimized for use case
Join Elimination Pre-compute expensive joins Order of magnitude speedup
Aggregation Pushdown Pre-compute aggregations Real-time analytics

Architecture

                        Materialized Views Architecture

  ┌─────────────────────────────────────────────────────────────────────┐
  │                         Query Layer                                  │
  │  ┌─────────────┐    ┌──────────────────┐    ┌─────────────────────┐│
  │  │ SQL Parser  │ -> │  Query Rewriter  │ -> │  Query Executor     ││
  │  └─────────────┘    └──────────────────┘    └─────────────────────┘│
  └──────────────────────────────┬──────────────────────────────────────┘
                                 v
  ┌─────────────────────────────────────────────────────────────────────┐
  │                    Materialized View Manager                         │
  │  ┌───────────────┐  ┌─────────────────┐  ┌────────────────────────┐│
  │  │ View Registry │  │ Refresh Manager │  │ Dependency Tracker     ││
  │  └───────────────┘  └─────────────────┘  └────────────────────────┘│
  └──────────────────────────────┬──────────────────────────────────────┘
                                 v
  ┌─────────────────────────────────────────────────────────────────────┐
  │                        Storage Layer                                 │
  │  ┌─────────┐  ┌─────────┐  ┌───────────┐  ┌────────────────────────┐│
  │  │   LSM   │  │ Memory  │  │ Columnar  │  │       Hybrid           ││
  │  └─────────┘  └─────────┘  └───────────┘  └────────────────────────┘│
  └─────────────────────────────────────────────────────────────────────┘

Feature Highlights

1. Incremental Refresh

Efficiently update views by processing only changed data:

// Record changes to source tables
let change = RowChange::insert(table_id, key, value, transaction_id);
engine.record_change(change).await?;

// Compute and apply delta (much faster than full refresh)
let delta = engine.compute_delta(view_id, &source_tables, view_size).await?;
engine.apply_delta(&delta).await?;

2. Flexible Refresh Strategies

Strategy Use Case Latency
Manual Development, testing On-demand
OnCommit Real-time requirements Milliseconds
Interval Regular updates Seconds to minutes
Cron Scheduled updates Any schedule

3. Intelligent Query Rewriting

Automatically substitute materialized views to accelerate queries:

  • Exact Match: Query matches view definition
  • Join Elimination: View pre-computes expensive joins
  • Aggregation Pushdown: View pre-computes aggregations
  • Superset Match: View contains query data plus more
  • Filter Pushdown: View has beneficial filters

Performance Benefits

Scenario Without MV With MV Speedup
Complex Join 500ms 5ms 100x
Large Aggregation 2s 10ms 200x
Dashboard Query 800ms 8ms 100x
OLAP Analytics 5s 50ms 100x

Use Cases

Use Case Recommended Strategy Description
Real-time Dashboards OnCommit Instant updates
Daily Reports Cron (midnight) Scheduled refresh
Session Analytics Interval (5min) Near-real-time
Historical Analysis Manual On-demand refresh

API Modules

Module Description
heliosdb_compute::materialized_views Main module
heliosdb_compute::materialized_views::incremental Incremental refresh
heliosdb_compute::materialized_views::refresh Refresh management
heliosdb_compute::materialized_views::rewrite Query rewriting
heliosdb_compute::materialized_views::dependencies Dependency tracking

See Also: HeliosDB Feature Index