From ae9fd26ebacf9f4992882d8bc5ffff41948b4376 Mon Sep 17 00:00:00 2001 From: Tudor Date: Fri, 27 Mar 2026 11:20:20 +0000 Subject: [PATCH] perf(dbt): materialize stg_ees_ks2 and stg_ees_ks4 as tables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit KS2 attainment has 1.2M rows in long format. As a view, the pivot was re-executed inline for every downstream model (intermediate → fact), causing fact_ks2_performance CREATE TABLE to run for 18+ minutes. Materializing as tables means the pivot runs once during staging, and downstream models read from a pre-computed ~16k-row result. Co-Authored-By: Claude Sonnet 4.6 --- pipeline/transform/models/staging/stg_ees_ks2.sql | 2 ++ pipeline/transform/models/staging/stg_ees_ks4.sql | 2 ++ 2 files changed, 4 insertions(+) diff --git a/pipeline/transform/models/staging/stg_ees_ks2.sql b/pipeline/transform/models/staging/stg_ees_ks2.sql index 4e33d89..e098a8b 100644 --- a/pipeline/transform/models/staging/stg_ees_ks2.sql +++ b/pipeline/transform/models/staging/stg_ees_ks2.sql @@ -1,3 +1,5 @@ +{{ config(materialized='table') }} + -- Staging model: KS2 attainment + information -- Pivots long-format attainment data (one row per subject × breakdown) into -- wide format (one row per school per year) and joins context from info table. diff --git a/pipeline/transform/models/staging/stg_ees_ks4.sql b/pipeline/transform/models/staging/stg_ees_ks4.sql index 7f12346..0c62220 100644 --- a/pipeline/transform/models/staging/stg_ees_ks4.sql +++ b/pipeline/transform/models/staging/stg_ees_ks4.sql @@ -1,3 +1,5 @@ +{{ config(materialized='table') }} + -- Staging model: KS4 attainment data from EES -- KS4 performance data is long-format with breakdown dimensions (breakdown_topic, -- breakdown, sex). Unlike KS2 which has a subject dimension, KS4 metrics are