Skip to content

Bmx_base_perpetual_trades performance#9442

Merged
tomfutago merged 2 commits intomainfrom
cursor/CUR2-1635-bmx-base-perpetual-trades-performance-cd33
Mar 16, 2026
Merged

Bmx_base_perpetual_trades performance#9442
tomfutago merged 2 commits intomainfrom
cursor/CUR2-1635-bmx-base-perpetual-trades-performance-cd33

Conversation

@jeff-dude
Copy link
Copy Markdown
Member

Thank you for contributing to Spellbook 🪄

Please open the PR in draft and mark as ready when you want to request a review.

Description:

Optimizes the bmx_base_perpetual_trades model to significantly reduce its runtime in hourly jobs.

The model was running longer than expected due to:

  1. Missing incremental_predicates: No partition pruning on the destination table during merge operations.
  2. Inefficient join to base.transactions: Only joining on tx_hash without block_number or block_date, leading to full table scans.
  3. Incorrect incremental filtering: The incremental predicate was not effectively applied to the base.transactions source, preventing its pruning.

This PR addresses these issues by:

  • Adding incremental_predicates to enable destination table pruning.
  • Enhancing the join to base.transactions with block_number and block_date to enable partition pruning on the source table.
  • Correcting the incremental filter to directly prune base.transactions based on trx.block_time.

These changes ensure more efficient data reads and joins, drastically improving the model's performance.


quick links for more information:


Linear Issue: CUR2-1635

Open in Web Open in Cursor 

…prove transaction join

- Add incremental_predicates config for merge partition pruning on destination table
- Add block_number and block_date to transactions join for partition pruning
- Filter transactions source directly (trx.block_time) instead of redundantly filtering events
- Prevents full scan of base.transactions on incremental runs

Co-authored-by: jeff-dude <jeff-dude@users.noreply.github.com>
@cursor
Copy link
Copy Markdown

cursor Bot commented Mar 10, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@github-actions github-actions Bot added WIP work in progress dbt: hourly covers the hourly dbt subproject labels Mar 10, 2026
@jeff-dude jeff-dude marked this pull request as ready for review March 10, 2026 12:47
@github-actions github-actions Bot added ready-for-review this PR development is complete, please review and removed WIP work in progress labels Mar 10, 2026
@jeff-dude jeff-dude added ready-for-merging and removed ready-for-review this PR development is complete, please review labels Mar 10, 2026
@jeff-dude jeff-dude requested a review from a team March 10, 2026 12:50
@tomfutago tomfutago merged commit d560a2c into main Mar 16, 2026
3 checks passed
@tomfutago tomfutago deleted the cursor/CUR2-1635-bmx-base-perpetual-trades-performance-cd33 branch March 16, 2026 09:09
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

dbt: hourly covers the hourly dbt subproject ready-for-merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants