:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(web-analytics): allow year-long lazy precompute spans (#104512)
Lucas Ricoye402c40064e8
diff --git a/products/web_analytics/backend/hogql_queries/test/test_web_lazy_precompute_common.py b/products/web_analytics/backend/hogql_queries/test/test_web_lazy_precompute_common.pyindex a54b92f15318..aee60d56d2b9 100644--- a/products/web_analytics/backend/hogql_queries/test/test_web_lazy_precompute_common.py+++ b/products/web_analytics/backend/hogql_queries/test/test_web_lazy_precompute_common.py@@ -42,7 +42,7 @@ from products.web_analytics.backend.hogql_queries.stats_table import WebStatsTabfrom products.web_analytics.backend.hogql_queries.web_analytics_lazy_precompute import can_use_lazy_precomputefrom products.web_analytics.backend.hogql_queries.web_lazy_precompute_common import (_VOLUME_FLOOR_LOCAL_CACHE,- CHANNEL_MAX_WINDOW_DAYS,+ LAZY_MAX_WINDOW_DAYS,OOM_PIN_TTL_SECONDS,REVALIDATION_START_DELAY_SECONDS,REVALIDATION_TRIGGER,@@ -60,7 +60,6 @@ from products.web_analytics.backend.hogql_queries.web_lazy_precompute_common imp_oom_pin_key,_sticky_team_count_key,_team_shape_set_key,- channel_ttl_schedule,check_common_eligibility,compute_filters_eligibility_hash,compute_shape_cap_key,@@ -71,6 +70,7 @@ from products.web_analytics.backend.hogql_queries.web_lazy_precompute_common impis_team_above_volume_floor,is_team_oom_pinned,lazy_precompute_ineligible_reason,+ lazy_ttl_schedule,log_eligibility_outcome,pin_team_oom,publish_volume_floor_teams,@@ -143,13 +143,15 @@ class TestChannelModifiersShapeKey(BaseTest):assert override_key != default_key-class TestChannelTtlSchedule(BaseTest):+class TestLazyTtlSchedule(BaseTest):def test_schedule_caps_job_width_and_holds_old_days(self) -> None:- # Without max_window_days, `split_ranges_by_ttl` merges a year-long span's- # 90-day-band tail into ONE insert; without the long default hold, annual- # shapes re-scan a year of events every three weeks.- schedule = channel_ttl_schedule(self.team)- assert schedule.max_window_days == CHANNEL_MAX_WINDOW_DAYS+ # Every family reaches MAX_PRECOMPUTE_DAYS, so both guards must hold for+ # every family. Without max_window_days, `split_ranges_by_ttl` merges a+ # year-long span's default-band tail into ONE insert; without the long+ # default hold, annual shapes re-scan a year of events every time the+ # band expires.+ schedule = lazy_ttl_schedule(self.team)+ assert schedule.max_window_days == LAZY_MAX_WINDOW_DAYSassert schedule.default_ttl_seconds == 90 * 24 * 60 * 60diff --git a/products/web_analytics/backend/hogql_queries/test/test_web_overview_lazy_precompute.py b/products/web_analytics/backend/hogql_queries/test/test_web_overview_lazy_precompute.pyindex d9e68a1ecff5..4da111e364ad 100644--- a/products/web_analytics/backend/hogql_queries/test/test_web_overview_lazy_precompute.py+++ b/products/web_analytics/backend/hogql_queries/test/test_web_overview_lazy_precompute.py@@ -529,8 +529,8 @@ class TestWebOverviewLazyPrecompute(ClickhouseTestMixin, APIBaseTest):@time_machine.travel("2024-01-15T12:00:00Z", tick=False)def test_window_over_max_days_falls_through(self):- # 365 days >> MAX_PRECOMPUTE_DAYS — gate refuses to avoid spawning- # hundreds of daily INSERT jobs in one request.+ # 371 days, past MAX_PRECOMPUTE_DAYS (366), so the gate refuses rather+ # than spawn more daily INSERT jobs than one shape can justify.self._seed_two_sessions()with self._enable_lazy():self._run(self._build_query(date_from="2023-01-01", date_to="2024-01-07"))diff --git a/products/web_analytics/backend/hogql_queries/test/test_web_stats_lazy_precompute.py b/products/web_analytics/backend/hogql_queries/test/test_web_stats_lazy_precompute.pyindex a9d6dc054076..dada2a2d1fd5 100644--- a/products/web_analytics/backend/hogql_queries/test/test_web_stats_lazy_precompute.py+++ b/products/web_analytics/backend/hogql_queries/test/test_web_stats_lazy_precompute.py@@ -53,6 +53,13 @@ PARITY_BREAKDOWNS = [("exit_page", WebStatsBreakdown.EXIT_PAGE),]+# The span gate measures `date_to - date_from` in whole days, so these three+# dates straddle MAX_PRECOMPUTE_DAYS exactly: 366 days from MAX_SPAN_DATE_FROM+# and 367 from OVER_MAX_SPAN_DATE_FROM.+SPAN_DATE_TO = "2024-01-07"+MAX_SPAN_DATE_FROM = "2023-01-06"+OVER_MAX_SPAN_DATE_FROM = "2023-01-05"+@override_settings(IN_UNIT_TESTING=True)class TestWebStatsLazyPrecompute(ClickhouseTestMixin, APIBaseTest):@@ -244,25 +251,43 @@ class TestWebStatsLazyPrecompute(ClickhouseTestMixin, APIBaseTest):assert lazy_response.preComputeStrategy == WebAnalyticsPreComputeStrategy.LAZY_PRECOMPUTEassert lazy == raw, f"lazy/raw mismatch under channel filter: raw={raw}, lazy={lazy}"+ @parameterized.expand(+ [+ (+ "channel_filtered",+ [SessionPropertyFilter(key="$channel_type", value="Direct", operator=PropertyOperator.EXACT)],+ False,+ ),+ ("unfiltered", [], False),+ ("with_compare_period", [], True),+ ]+ )@time_machine.travel("2024-01-15T12:00:00Z", tick=False)- def test_channel_filter_over_max_days_still_admitted(self):- # The gate check the customer path depends on: a channel-filtered range- # past MAX_PRECOMPUTE_DAYS (90) but under CHANNEL_MAX_PRECOMPUTE_DAYS- # (366) must stay eligible instead of DateRangeOverMax falling to live.- props = [SessionPropertyFilter(key="$channel_type", value="Direct", operator=PropertyOperator.EXACT)]+ def test_year_long_range_stays_admitted(self, _name: str, props: list, compare: bool):+ # Sits exactly on MAX_PRECOMPUTE_DAYS (366), so any narrower cap sends a+ # "this year" tile back to the live path through DateRangeOverMax. The+ # compare case pins the measured span to the current period: the previous+ # period gets its own `ensure_web_stats_precomputed` call (parity covered+ # by `test_lazy_matches_raw_with_compare`), so a gate measuring both would+ # see ~732 days and reject.runner = WebStatsTableQueryRunner(team=self.team,- query=self._build_query(properties=props, date_from="2023-06-01", date_to="2024-01-07"),+ query=self._build_query(+ properties=props, date_from=MAX_SPAN_DATE_FROM, date_to=SPAN_DATE_TO, compare=compare+ ),)with self._enable_lazy():assert can_use_stats_lazy_precompute(runner)- unfiltered = WebStatsTableQueryRunner(+ @time_machine.travel("2024-01-15T12:00:00Z", tick=False)+ def test_range_one_day_past_max_falls_through(self):+ # One day wider than the case above, so the cap bites at 367 days.+ runner = WebStatsTableQueryRunner(team=self.team,- query=self._build_query(date_from="2023-06-01", date_to="2024-01-07"),+ query=self._build_query(date_from=OVER_MAX_SPAN_DATE_FROM, date_to=SPAN_DATE_TO),)with self._enable_lazy():- assert not can_use_stats_lazy_precompute(unfiltered), "the 366-day cap is channel-scoped, not general"+ assert not can_use_stats_lazy_precompute(runner)@time_machine.travel("2024-01-15T12:00:00Z", tick=False)def test_uuid_session_mode_stays_rejected_with_channel_filter(self):diff --git a/products/web_analytics/backend/hogql_queries/web_analytics_lazy_precompute.py b/products/web_analytics/backend/hogql_queries/web_analytics_lazy_precompute.pyindex cfc0920a23b5..bad1402d6582 100644--- a/products/web_analytics/backend/hogql_queries/web_analytics_lazy_precompute.py+++ b/products/web_analytics/backend/hogql_queries/web_analytics_lazy_precompute.py@@ -30,9 +30,10 @@ from posthog.models.team import Teamfrom products.access_control.backend.facade.api import team_has_property_access_rulesfrom products.web_analytics.backend.hogql_queries.web_lazy_precompute_common import (LAZY_TTL_SECONDS, # noqa: F401 — re-exported; several runners import it from this module- channel_ttl_schedule, # noqa: F401 — re-exported alongside the channel constants below+ MAX_PRECOMPUTE_DAYS,is_precompute_enabled_for_team,is_team_above_volume_floor,+ lazy_ttl_schedule, # noqa: F401 — re-exported alongside the TTL constants belowset_lazy_precompute_ineligible_reason,)@@ -70,17 +71,6 @@ WEB_ANALYTICS_LAZY_PRECOMPUTE_SUCCESS = Counter(# (their content is hashed into the cache key).SUPPORTED_USER_FILTER_KEYS: set[str] = {"$host"}-# Upper bound on the precompute span. Above this, the framework would create-# enough daily jobs that the first request burns INSERT slots for minutes.-MAX_PRECOMPUTE_DAYS = 90--# Channel-filtered shapes accept a full year (+leap): the whole point of admitting-# the `$channel_type` filter is the long-range dashboards it appears on, and-# `channel_ttl_schedule`'s job-width cap bounds each insert regardless of span.-# Cold spans build behind the live fallback, so the first request never burns-# the slots itself.-CHANNEL_MAX_PRECOMPUTE_DAYS = 366-# Forward pad on the per-job event-scan window. The lazy_computation framework# chunks the precompute span into daily UTC jobs; each job covers# `[time_window_min, time_window_max)`. A session starting at 23:50 with eventsdiff --git a/products/web_analytics/backend/hogql_queries/web_goals_lazy_precompute.py b/products/web_analytics/backend/hogql_queries/web_goals_lazy_precompute.pyindex e27344152872..cd1949268c8f 100644--- a/products/web_analytics/backend/hogql_queries/web_goals_lazy_precompute.py+++ b/products/web_analytics/backend/hogql_queries/web_goals_lazy_precompute.py@@ -39,7 +39,6 @@ from products.analytics_platform.backend.lazy_computation.lazy_computation_execuLazyComputationTable,)from products.web_analytics.backend.hogql_queries.web_lazy_precompute_common import (- LAZY_TTL_SECONDS,SESSION_FORWARD_PAD_MINUTES,LazyPrecomputeIneligible,ceil_utc_day,@@ -47,6 +46,7 @@ from products.web_analytics.backend.hogql_queries.web_lazy_precompute_common impfloor_utc_day,handle_stale_served,host_filter_expr,+ lazy_ttl_schedule,log_eligibility_outcome,test_account_filter_expr,web_ensure_precomputed,@@ -307,7 +307,7 @@ def ensure_web_goals_precomputed(insert_query=_build_insert_query(actions),time_range_start=time_range_start,time_range_end=time_range_end,- ttl_seconds=LAZY_TTL_SECONDS,+ ttl_seconds=lazy_ttl_schedule(runner.team),table=LazyComputationTable.WEB_GOALS_PREAGGREGATED,placeholders=placeholders,query_type="web_goals_lazy_insert",diff --git a/products/web_analytics/backend/hogql_queries/web_lazy_precompute_common.py b/products/web_analytics/backend/hogql_queries/web_lazy_precompute_common.pyindex a6485e1eb863..a296cc9f1137 100644--- a/products/web_analytics/backend/hogql_queries/web_lazy_precompute_common.py+++ b/products/web_analytics/backend/hogql_queries/web_lazy_precompute_common.py@@ -758,9 +758,11 @@ _FILTERS_ELIGIBILITY_HASH_IGNORED_QUERY_FIELDS: frozenset[str] = frozenset(# Windows aged 2+ days are *session-final*: sessions cap at 24h (the insert# scans window_end+24h), so bounce/duration can no longer change, and# measured late-event ingestion beyond 49h is ≤0.03% of pageviews on the-# worst enrolled team (~0% elsewhere). Their TTLs are therefore generous —-# recomputing an immutable window buys nothing — and bounded in practice by-# hash rotations (any AST-affecting deploy rebuilds everything anyway).+# worst enrolled team (~0% elsewhere). Their TTLs are therefore generous,+# because recomputing an immutable window buys nothing, and bounded in+# practice by hash rotations (any AST-affecting deploy rebuilds everything+# anyway). The `default` band holds 90 days so that a year-long shape does+# not re-scan a year of events every time the band expires.# 2. Job sizing — `split_ranges_by_ttl` merges *consecutive days with the same# TTL* into one job. Distinct per-week TTLs therefore force weekly job# boundaries, so a 31-day warm splits into ≤7-day jobs instead of one ~24-day@@ -775,25 +777,20 @@ LAZY_TTL_SECONDS: dict[str, int] = {"21d": 10 * 24 * 60 * 60, # days 15–21 → one 7d job"28d": 12 * 24 * 60 * 60, # days 22–28 → one 7d job"35d": 14 * 24 * 60 * 60, # days 29–35 → one 7d job (covers the tail of a 31d warm)- "default": 21 * 24 * 60 * 60, # days 36++ "default": 90 * 24 * 60 * 60, # days 36+}-# TTL schedule for channel-filtered shapes: same graded bands for recent days,-# but old immutable days are held for 90 days instead of 21 — without the longer-# hold, a year-long shape re-scans a year of events every three weeks per shape.-CHANNEL_TTL_SECONDS: dict[str, int] = {**LAZY_TTL_SECONDS, "default": 90 * 24 * 60 * 60}+# Job-width cap. `split_ranges_by_ttl` merges consecutive days sharing one TTL+# band into a single job, so the `default` band above would put a year-long+# span's whole tail into ONE insert without this cap. Seven days keeps each+# insert bounded (a 366-day backfill runs as ~53 jobs) while the reactive OOM+# pin can still tighten a pathological team to 1-day windows.+LAZY_MAX_WINDOW_DAYS = 7-# Job-width cap for channel shapes. `split_ranges_by_ttl` merges consecutive days-# sharing one TTL band into a single job, so the 90-day band above would put a-# year-long span's whole tail into ONE insert without this cap. Seven days keeps-# each insert bounded (a 366-day backfill runs as ~53 jobs) while the reactive-# OOM pin can still tighten a pathological team to 1-day windows.-CHANNEL_MAX_WINDOW_DAYS = 7--def channel_ttl_schedule(team: Team) -> TtlSchedule:- """The channel-filtered shapes' TTL schedule, with the job-width cap applied."""- return parse_ttl_schedule(CHANNEL_TTL_SECONDS, team.timezone, max_window_days=CHANNEL_MAX_WINDOW_DAYS)+def lazy_ttl_schedule(team: Team) -> TtlSchedule:+ """The lazy precompute TTL schedule, with the job-width cap applied."""+ return parse_ttl_schedule(LAZY_TTL_SECONDS, team.timezone, max_window_days=LAZY_MAX_WINDOW_DAYS)# MVP user-filter allowlist: only an EventPropertyFilter on `$host` with@@ -801,9 +798,12 @@ def channel_ttl_schedule(team: Team) -> TtlSchedule:# (their content is hashed into the cache key).SUPPORTED_USER_FILTER_KEYS: set[str] = {"$host"}-# Upper bound on the precompute span. Above this, the framework would create-# enough daily jobs that the first request burns INSERT slots for minutes.-MAX_PRECOMPUTE_DAYS = 90+# Upper bound on the precompute span: a full year plus a leap day, which covers+# the "this year" and "last 12 months" dashboards these shapes appear on. Span+# width does not size an insert, because `LAZY_MAX_WINDOW_DAYS` caps job width+# independently, and cold spans build behind the live fallback, so the first+# request never burns the slots itself.+MAX_PRECOMPUTE_DAYS = 366# Forward pad on the per-job event-scan window. Matches the JS SDK's# 24 h hard SESSION_LENGTH_LIMIT and covers ~100% of population sessions.diff --git a/products/web_analytics/backend/hogql_queries/web_overview_lazy_precompute.py b/products/web_analytics/backend/hogql_queries/web_overview_lazy_precompute.pyindex 234562935757..eaed72b7055a 100644--- a/products/web_analytics/backend/hogql_queries/web_overview_lazy_precompute.py+++ b/products/web_analytics/backend/hogql_queries/web_overview_lazy_precompute.py@@ -25,21 +25,18 @@ from products.analytics_platform.backend.lazy_computation.lazy_computation_execuLazyComputationTable,)from products.web_analytics.backend.hogql_queries.web_analytics_lazy_precompute import (- CHANNEL_MAX_PRECOMPUTE_DAYS,- LAZY_TTL_SECONDS,- MAX_PRECOMPUTE_DAYS,SESSION_FORWARD_PAD_MINUTES,WEB_ANALYTICS_LAZY_PRECOMPUTE_FALLBACK,WEB_ANALYTICS_LAZY_PRECOMPUTE_SUCCESS,can_use_lazy_precompute as _can_use_lazy_precompute_shared,ceil_utc_day,channel_rules_shape_key,- channel_ttl_schedule,check_common_eligible,events_session_id_expr,floor_utc_day,has_channel_type_filter,is_constant_true,+ lazy_ttl_schedule,test_account_filter_expr,user_filter_expr,with_insert_session_id_set_filter,@@ -71,7 +68,6 @@ def can_use_lazy_precompute(runner: "WebOverviewQueryRunner") -> bool:allow_channel_type_filter=has_channel_type_filter(runner),# Overview-only: its channel template carries the UUID-safe session-id handling.allow_uuid_session_join=has_channel_type_filter(runner),- max_days=CHANNEL_MAX_PRECOMPUTE_DAYS if has_channel_type_filter(runner) else MAX_PRECOMPUTE_DAYS,)@@ -80,7 +76,6 @@ def _check_lazy_precompute_eligible(runner: "WebOverviewQueryRunner") -> None:runner,allow_channel_type_filter=has_channel_type_filter(runner),allow_uuid_session_join=has_channel_type_filter(runner),- max_days=CHANNEL_MAX_PRECOMPUTE_DAYS if has_channel_type_filter(runner) else MAX_PRECOMPUTE_DAYS,)@@ -252,7 +247,7 @@ def ensure_web_overview_precomputed(insert_query=insert_query,time_range_start=time_range_start,time_range_end=time_range_end,- ttl_seconds=channel_ttl_schedule(runner.team) if has_channel_type_filter(runner) else LAZY_TTL_SECONDS,+ ttl_seconds=lazy_ttl_schedule(runner.team),table=LazyComputationTable.WEB_OVERVIEW_PREAGGREGATED,placeholders=placeholders,query_type="web_overview_lazy_insert",diff --git a/products/web_analytics/backend/hogql_queries/web_stats_frustration_lazy_precompute.py b/products/web_analytics/backend/hogql_queries/web_stats_frustration_lazy_precompute.pyindex 161ce588aecc..dbd1339df271 100644--- a/products/web_analytics/backend/hogql_queries/web_stats_frustration_lazy_precompute.py+++ b/products/web_analytics/backend/hogql_queries/web_stats_frustration_lazy_precompute.py@@ -29,7 +29,6 @@ from products.analytics_platform.backend.lazy_computation.lazy_computation_execuLazyComputationTable,)from products.web_analytics.backend.hogql_queries.web_lazy_precompute_common import (- LAZY_TTL_SECONDS,SESSION_FORWARD_PAD_MINUTES,LazyPrecomputeIneligible,ceil_utc_day,@@ -37,6 +36,7 @@ from products.web_analytics.backend.hogql_queries.web_lazy_precompute_common impfloor_utc_day,handle_stale_served,host_filter_expr,+ lazy_ttl_schedule,log_eligibility_outcome,test_account_filter_expr,web_ensure_precomputed,@@ -273,7 +273,7 @@ def ensure_web_stats_frustration_precomputed(insert_query=INSERT_QUERY_TEMPLATE,time_range_start=time_range_start,time_range_end=time_range_end,- ttl_seconds=LAZY_TTL_SECONDS,+ ttl_seconds=lazy_ttl_schedule(runner.team),table=LazyComputationTable.WEB_STATS_FRUSTRATION_PREAGGREGATED,placeholders=placeholders,query_type="web_stats_frustration_lazy_insert",diff --git a/products/web_analytics/backend/hogql_queries/web_stats_lazy_precompute.py b/products/web_analytics/backend/hogql_queries/web_stats_lazy_precompute.pyindex b21d70b35a44..4a59c2604f8e 100644--- a/products/web_analytics/backend/hogql_queries/web_stats_lazy_precompute.py+++ b/products/web_analytics/backend/hogql_queries/web_stats_lazy_precompute.py@@ -25,9 +25,6 @@ from products.analytics_platform.backend.lazy_computation.lazy_computation_execuLazyComputationTable,)from products.web_analytics.backend.hogql_queries.web_analytics_lazy_precompute import (- CHANNEL_MAX_PRECOMPUTE_DAYS,- LAZY_TTL_SECONDS,- MAX_PRECOMPUTE_DAYS,SESSION_FORWARD_PAD_MINUTES,WEB_ANALYTICS_LAZY_PRECOMPUTE_FALLBACK,WEB_ANALYTICS_LAZY_PRECOMPUTE_SUCCESS,@@ -36,10 +33,10 @@ from products.web_analytics.backend.hogql_queries.web_analytics_lazy_precomputecan_use_lazy_precompute as _can_use_lazy_precompute_shared,ceil_utc_day,channel_rules_shape_key,- channel_ttl_schedule,events_session_id_expr,floor_utc_day,has_channel_type_filter,+ lazy_ttl_schedule,test_account_filter_expr,user_filter_expr,with_channel_rules_key,@@ -218,7 +215,6 @@ def can_use_lazy_precompute(runner: "WebStatsTableQueryRunner") -> bool:log_prefix="web_stats",extra_check=_check_stats_eligible,allow_channel_type_filter=channel,- max_days=CHANNEL_MAX_PRECOMPUTE_DAYS if channel else MAX_PRECOMPUTE_DAYS,)@@ -315,7 +311,7 @@ def ensure_web_stats_precomputed(insert_query=INSERT_QUERY_TEMPLATE,time_range_start=time_range_start,time_range_end=time_range_end,- ttl_seconds=channel_ttl_schedule(runner.team) if channel else LAZY_TTL_SECONDS,+ ttl_seconds=lazy_ttl_schedule(runner.team),table=LazyComputationTable.WEB_STATS_PREAGGREGATED,placeholders=placeholders,query_type=f"web_stats_{runner.query.breakdownBy.value}_lazy_insert",diff --git a/products/web_analytics/backend/hogql_queries/web_stats_paths_lazy_precompute.py b/products/web_analytics/backend/hogql_queries/web_stats_paths_lazy_precompute.pyindex 8844cee9c772..591c86f50ee2 100644--- a/products/web_analytics/backend/hogql_queries/web_stats_paths_lazy_precompute.py+++ b/products/web_analytics/backend/hogql_queries/web_stats_paths_lazy_precompute.py@@ -36,7 +36,6 @@ from products.analytics_platform.backend.lazy_computation.lazy_computation_execuLazyComputationTable,)from products.web_analytics.backend.hogql_queries.web_analytics_lazy_precompute import (- CHANNEL_MAX_PRECOMPUTE_DAYS,build_insert_select_ast,channel_rules_shape_key,has_channel_type_filter,@@ -44,17 +43,15 @@ from products.web_analytics.backend.hogql_queries.web_analytics_lazy_precomputewith_channel_rules_key,)from products.web_analytics.backend.hogql_queries.web_lazy_precompute_common import (- LAZY_TTL_SECONDS,- MAX_PRECOMPUTE_DAYS,SESSION_FORWARD_PAD_MINUTES,LazyPrecomputeIneligible,ceil_utc_day,- channel_ttl_schedule,check_common_eligibility,floor_utc_day,handle_stale_served,host_filter_expr,is_background_warming_request,+ lazy_ttl_schedule,log_eligibility_outcome,test_account_filter_expr,web_ensure_precomputed,@@ -186,7 +183,6 @@ def _check_eligible(runner: "WebStatsTableQueryRunner") -> None:properties=query.properties or [],resolve_date_range=lambda: (runner.query_date_range.date_from(), runner.query_date_range.date_to()),allow_channel_type_filter=channel,- max_days=CHANNEL_MAX_PRECOMPUTE_DAYS if channel else MAX_PRECOMPUTE_DAYS,)@@ -666,7 +662,7 @@ def ensure_web_stats_paths_precomputed(insert_query=insert_query,time_range_start=time_range_start,time_range_end=time_range_end,- ttl_seconds=channel_ttl_schedule(runner.team) if channel else LAZY_TTL_SECONDS,+ ttl_seconds=lazy_ttl_schedule(runner.team),table=LazyComputationTable.WEB_STATS_PATHS_PREAGGREGATED,placeholders=placeholders,query_type="web_stats_paths_lazy_insert",diff --git a/products/web_analytics/backend/hogql_queries/web_vitals_paths_lazy_precompute.py b/products/web_analytics/backend/hogql_queries/web_vitals_paths_lazy_precompute.pyindex 8496fe4104e3..9e24c30c7ad2 100644--- a/products/web_analytics/backend/hogql_queries/web_vitals_paths_lazy_precompute.py+++ b/products/web_analytics/backend/hogql_queries/web_vitals_paths_lazy_precompute.py@@ -31,7 +31,6 @@ from products.analytics_platform.backend.lazy_computation.lazy_computation_execuLazyComputationTable,)from products.web_analytics.backend.hogql_queries.web_analytics_lazy_precompute import (- LAZY_TTL_SECONDS,WEB_ANALYTICS_LAZY_PRECOMPUTE_FALLBACK,WEB_ANALYTICS_LAZY_PRECOMPUTE_SUCCESS,LazyPrecomputeIneligible,@@ -39,6 +38,7 @@ from products.web_analytics.backend.hogql_queries.web_analytics_lazy_precomputecan_use_lazy_precompute as _can_use_lazy_precompute_shared,ceil_utc_day,floor_utc_day,+ lazy_ttl_schedule,test_account_filter_expr,user_filter_expr,)@@ -213,7 +213,7 @@ def ensure_web_vitals_paths_precomputed(insert_query=INSERT_QUERY_TEMPLATE,time_range_start=time_range_start,time_range_end=time_range_end,- ttl_seconds=LAZY_TTL_SECONDS,+ ttl_seconds=lazy_ttl_schedule(runner.team),table=LazyComputationTable.WEB_VITALS_PATHS_PREAGGREGATED,placeholders=placeholders,query_type="web_vitals_paths_lazy_insert",diff --git a/products/web_analytics/dags/tests/test_cache_warming.py b/products/web_analytics/dags/tests/test_cache_warming.pyindex 85a31ce5c7d8..f072e74a2de3 100644--- a/products/web_analytics/dags/tests/test_cache_warming.py+++ b/products/web_analytics/dags/tests/test_cache_warming.py@@ -262,7 +262,7 @@ class TestBuildReplayRunner(BaseTest):# buckets the shape's real queries can never consume, held only to# the lazy demand floor instead of the raw one.("uuid_join_mode", {"modifiers": {"sessionsV2JoinMode": "uuid"}}, ["-7d"], "-7d"),- ("only_over_cap_demand", {"dateRange": {"date_from": "-180d"}}, ["-180d"], "-180d"),+ ("only_over_cap_demand", {"dateRange": {"date_from": "-400d"}}, ["-400d"], "-400d"),])def test_ineligible_shape_is_not_canonicalized_into_eligibility(diff --git a/products/web_analytics/dags/web_dimensional_precompute.py b/products/web_analytics/dags/web_dimensional_precompute.pyindex df40f59ba758..e56f214b5bde 100644--- a/products/web_analytics/dags/web_dimensional_precompute.py+++ b/products/web_analytics/dags/web_dimensional_precompute.py@@ -41,8 +41,11 @@ from products.web_analytics.dags.web_preaggregated_utils import check_for_concurlogger = structlog.get_logger(__name__)-# Rolling window kept warm. Matches the lazy precompute MAX_PRECOMPUTE_DAYS so a-# later read path can serve any sub-window without falling back to raw tables.+# Rolling window kept warm, so that a later read path can serve any sub-window+# without falling back to raw tables. Sized independently of the lazy precompute+# `MAX_PRECOMPUTE_DAYS`, because this window is a fixed cost the dag pays for+# every enrolled team, not a per-shape span the tenant's own demand bounds.+# Widen it through the env var once the storage cost is agreed.PRECOMPUTE_WINDOW_DAYS = int(os.getenv("WEB_DIMENSIONAL_PRECOMPUTE_WINDOW_DAYS", "90"))# Each ensure_precomputed call covers at most this many days. The framework merges