Commit 4d05c57
feat(optimize_spell): skip OPTIMIZE on incremental no-op runs (#9679)
Make optimize_spell conditional on rows_affected for incremental
models: skip ALTER TABLE EXECUTE optimize when the just-run main
statement wrote fewer than OPTIMIZE_MIN_ROWS rows (default 1000).
Measurement across 5 representative cadence runs (Hourly, Tokens,
Daily, DEX, Solana, last 7 days) showed ~25% of incremental model
runs MERGE zero rows, with the OPTIMIZE post-hook accounting for an
estimated ~30% of total dbt execute time. Several chainlink_bnb and
chainlink_polygon models burn 700-1000+ seconds per Daily run with
0 rows merged.
The threshold is overridable globally via --vars '{OPTIMIZE_MIN_ROWS: N}'
or per-model via the optimize_min_rows config. Table materialization
keeps the existing always-optimize behavior.
Estimated savings (per cadence cycle): 5h at threshold=1, 11h at
threshold=1000, 13h at threshold=10000. Conservative go-live default
of 1000 captures most of the win with minimal risk.
Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com>1 parent c63ec2f commit 4d05c57
1 file changed
Lines changed: 52 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
1 | 30 | | |
2 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
3 | 38 | | |
4 | | - | |
| 39 | + | |
5 | 40 | | |
6 | | - | |
| 41 | + | |
7 | 42 | | |
8 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
9 | 58 | | |
10 | 59 | | |
0 commit comments