Skip to content
System Note 07 · Enterprise Systems

Query Optimization Framework

Bell Canada

SQLPerformance TuningData ModelingOptimization
Live
What it is

A rework of how a reporting job reads a 23-million-row device inventory table on Teradata. The old query joined everything and filtered later; the new one filters the lookups first, pushes predicates down into them, and accounts for key skew.

Why I built it

A 12-minute join was too slow to ship; it had to be fast before go-live.

What went wrong
  1. 01
    The whale join
    Broke
    In pre-go-live testing, a reporting query against the 23M-row device table ran 12 minutes.
    Why
    The job joined the full inventory table to the full classification table before filtering anything (join everything, filter later).
    Fix
    Flipped the order: filter the lookups first, push the predicates down into them, and analyze the key skew. Runtime fell from 12 minutes to 2 before go-live.
Outcome
83%faster join
Query plan (abridged)
Before
Rows
23M
Runtime
12 min
Reduction
baseline
  • Pre-tuning baseline
After
Rows
23M
Runtime
2 min
Reduction
83%
  • Filtered lookups
  • Predicate pushdown
  • Skew analysis

23M-row join. 12 min → 2 min, before go-live.

← Back to Build Notes