Skip to content

Materialized Views


Overview

HeliosDB accepts the PostgreSQL materialized-view statements today and runs each materialized view as a view. The planned design adds pre-computed results that are kept up to date by incremental refresh, refresh scheduling and transparent query rewriting, to speed up read-heavy workloads.

Key Capabilities

CapabilityDescriptionBenefitAvailability
View definitionCREATE MATERIALIZED VIEW ... AS SELECT, DROP MATERIALIZED VIEWPostgreSQL-compatible DDLAvailable (runs as a view)
Incremental RefreshUpdate only changed data10-100x faster refreshPlanned
Flexible SchedulingManual, on-commit, interval, cronMatch the workload patternPlanned
Query RewritingAutomatic view substitutionTransparent optimizationPlanned
Multiple Storage BackendsLSM, Memory, Columnar, HybridStorage chosen per use casePlanned
Join EliminationPre-compute expensive joinsOrder of magnitude speedupPlanned
Aggregation PushdownPre-compute aggregationsReal-time analyticsPlanned

Architecture (planned)

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 ││
│ └─────────┘ └─────────┘ └───────────┘ └────────────────────────┘│
└─────────────────────────────────────────────────────────────────────┘

Planned Feature Highlights

1. Incremental Refresh

Update views by processing only changed data.

2. Flexible Refresh Strategies

StrategyUse CaseLatency
ManualDevelopment, testingOn-demand
OnCommitReal-time requirementsMilliseconds
IntervalRegular updatesSeconds to minutes
CronScheduled updatesAny schedule

3. 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

The figures below are indicative, measured on representative fixtures; reproduce on your own hardware.

ScenarioWithout MVWith MVSpeedup
Complex Join500ms5ms100x
Large Aggregation2s10ms200x
Dashboard Query800ms8ms100x
OLAP Analytics5s50ms100x

Use Cases

Recommended refresh strategies once stored materialized views are available:

Use CaseRecommended StrategyDescription
Real-time DashboardsOnCommitInstant updates
Daily ReportsCron (midnight)Scheduled refresh
Session AnalyticsInterval (5min)Near-real-time
Historical AnalysisManualOn-demand refresh

See Also: HeliosDB Feature Index