Skip to content

Commit 85e2cac

Browse files
authored
perf(addresses_events): shrink first_activity lookback to profiled late-arrival bound (#9783)
* perf(addresses_events): shrink first_activity lookback to profiled late-arrival bound Shrink the incremental re-scan window on the addresses_events <chain>_first_activity family from a hardcoded 7d to the CUR2-2678 profiled landing-lag bound: 2d for EVM chains, 3d for bnb. These models append only genuinely-new addresses (anti-join against the existing table), so the wide window only ever served to catch late-arriving first transactions -- measured at p99.9 = minutes for EVM and 6.6h (worst tail 1.9d) for bnb, far inside the new bounds. Parameterize the shared macro (lookback_days, default 2; bnb passes 3) and update the 15 inline chain models. * perf(addresses_events): use standard incremental_predicate lookback Replace model-specific lookback windows (interval '2'/'3' day) with the repo-standard incremental_predicate() macro across the 15 inline first_activity models and the shared macro. Drop the now-dead lookback_days param from the macro and from bnb's macro call. The 3-day standard window is strictly wider than the 2-day windows this PR introduced, so it can only include more rows in the rebuild window -- no first-activity rows can be missed.
1 parent b78a058 commit 85e2cac

16 files changed

Lines changed: 16 additions & 16 deletions

dbt_subprojects/hourly_spellbook/macros/sector/addresses_events/addresses_events_first_activity.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ LEFT JOIN (
2525
{% if is_incremental() %}
2626
LEFT JOIN {{this}} ffb ON et."from" = ffb.address
2727
WHERE ffb.address IS NULL
28-
AND et.block_time >= date_trunc('day', now() - interval '7' day)
28+
AND {{ incremental_predicate('et.block_time') }}
2929
{% endif %}
3030

3131
GROUP BY et."from"

dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/base/addresses_events_base_first_activity.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ LEFT JOIN (
3131
{% if is_incremental() %}
3232
LEFT JOIN {{this}} ffb ON et."from" = ffb.address
3333
WHERE ffb.address IS NULL
34-
AND et.block_time >= date_trunc('day', now() - interval '7' day)
34+
AND {{ incremental_predicate('et.block_time') }}
3535
{% endif %}
3636

3737
GROUP BY et."from"

dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/ink/addresses_events_ink_first_activity.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ LEFT JOIN (
3131
{% if is_incremental() %}
3232
LEFT JOIN {{this}} ffb ON et."from" = ffb.address
3333
WHERE ffb.address IS NULL
34-
AND et.block_time >= date_trunc('day', now() - interval '7' day)
34+
AND {{ incremental_predicate('et.block_time') }}
3535
{% endif %}
3636

3737
GROUP BY et."from"

dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/linea/addresses_events_linea_first_activity.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ LEFT JOIN (
3131
{% if is_incremental() %}
3232
LEFT JOIN {{this}} ffb ON et."from" = ffb.address
3333
WHERE ffb.address IS NULL
34-
AND et.block_time >= date_trunc('day', now() - interval '7' day)
34+
AND {{ incremental_predicate('et.block_time') }}
3535
{% endif %}
3636

3737
GROUP BY et."from"

dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/mantle/addresses_events_mantle_first_activity.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ LEFT JOIN (
3131
{% if is_incremental() %}
3232
LEFT JOIN {{this}} ffb ON et."from" = ffb.address
3333
WHERE ffb.address IS NULL
34-
AND et.block_time >= date_trunc('day', now() - interval '7' day)
34+
AND {{ incremental_predicate('et.block_time') }}
3535
{% endif %}
3636

3737
GROUP BY et."from"

dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/nova/addresses_events_nova_first_activity.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ LEFT JOIN (
3131
{% if is_incremental() %}
3232
LEFT JOIN {{this}} ffb ON et."from" = ffb.address
3333
WHERE ffb.address IS NULL
34-
AND et.block_time >= date_trunc('day', now() - interval '7' day)
34+
AND {{ incremental_predicate('et.block_time') }}
3535
{% endif %}
3636

3737
GROUP BY et."from"

dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/opbnb/addresses_events_opbnb_first_activity.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ LEFT JOIN (
3131
{% if is_incremental() %}
3232
LEFT JOIN {{this}} ffb ON et."from" = ffb.address
3333
WHERE ffb.address IS NULL
34-
AND et.block_time >= date_trunc('day', now() - interval '7' day)
34+
AND {{ incremental_predicate('et.block_time') }}
3535
{% endif %}
3636

3737
GROUP BY et."from"

dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/optimism/addresses_events_optimism_first_activity.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ FROM (
5959
gas_used
6060
FROM
6161
{{ source('optimism', 'transactions') }}
62-
WHERE block_time >= date_trunc('day', now() - interval '7' day)
62+
WHERE {{ incremental_predicate('block_time') }}
6363
{% endif %}
6464
) et
6565
LEFT JOIN (

dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/ronin/addresses_events_ronin_first_activity.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ LEFT JOIN (
3131
{% if is_incremental() %}
3232
LEFT JOIN {{this}} ffb ON et."from" = ffb.address
3333
WHERE ffb.address IS NULL
34-
AND et.block_time >= date_trunc('day', now() - interval '7' day)
34+
AND {{ incremental_predicate('et.block_time') }}
3535
{% endif %}
3636

3737
GROUP BY et."from"

dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/scroll/addresses_events_scroll_first_activity.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ LEFT JOIN (
3131
{% if is_incremental() %}
3232
LEFT JOIN {{this}} ffb ON et."from" = ffb.address
3333
WHERE ffb.address IS NULL
34-
AND et.block_time >= date_trunc('day', now() - interval '7' day)
34+
AND {{ incremental_predicate('et.block_time') }}
3535
{% endif %}
3636

3737
GROUP BY et."from"

0 commit comments

Comments
 (0)