This repository was archived by the owner on May 11, 2026. It is now read-only.
perf: add materialized view for aircraft stats dashboard#13
Open
okane16 wants to merge 6 commits into
Open
Conversation
The aircraftSpeedAltitudeByType query scans 63M+ rows (1.6 GB) on every dashboard load, taking 3.5-4.7 seconds. Add an AggregatingMergeTree target table populated by an incremental MaterializedView that pre-aggregates stats by category at insert time. The API now reads ~10 pre-aggregated rows (fast path) for the default dashboard view, falling back to the full scan only when altitude/speed range filters are active. Made-with: Cursor
Fix hosting build failure caused by version mismatch between the locked moose-lib (0.6.493) and the CI-resolved moose-cli (0.6.495). Made-with: Cursor
|
The latest updates on your projects. Learn more about Boreal.
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
aircraftSpeedAltitudeByTypedashboard query is the #1 slowest query in production, scanning 63.9M rows (1.66 GB) on every page load to produce 30 aggregated rows. This PR adds an incrementalAggregatingMergeTreematerialized view that pre-computes category-level stats at insert time, reducing the dashboard query from a full table scan to reading ~41 pre-aggregated rows.Changes
moose/app/ingest/aircraft_stats_mv.ts— definesAircraftStatsByCategoryTable(AggregatingMergeTree) andAircraftStatsByCategoryMV(incremental MV overAircraftTrackingProcessedTable)moose/app/apis/aircraftSpeedAltitudeByType.ts— fast path reads from the MV target table for the default (unfiltered) dashboard load; falls back to the full table scan only when altitude/speed range filters are activemoose/app/index.ts— exports the new MV resourcesmoose-libandmoose-clifrom 0.6.493 → 0.6.495 (fixes hosting build version mismatch)Benchmark Results
Benchmarked on production ClickHouse (main branch, 63.9M rows):
EXPLAIN Comparison
Baseline:
Candidate:
Caveats
INSERT INTO ... SELECTis recommended after merge to cover historical data.Test Plan
npx tsc --noEmit)moose lsdetects the new table and MVMade with Cursor