Conversation
…spend-cap Switch getWorkflowGasTotal (summary current + previous period) and the workflow portion of getSpendCapData to SUM workflow_executions.gas_used_wei instead of re-extracting and summing the per-step logs JSONB. Removes the logs join, the JSONB parse, and the TOAST detoast - the org+window slice is aggregated straight off workflow_executions with the date filter pushed into idx_workflow_executions_workflow_started. Staging proxy EXPLAIN (heaviest org, 30d): 2140ms / 5.1GB -> 397ms / 162MB. Gas is now windowed by run start (workflow_executions.started_at) rather than per-step time, consistent with the other summary metrics. Depends on the denormalized columns and backfill from the previous PR.
…ad-column perf: switch analytics gas reads to the denormalized column
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Promotes
stagingtoprod- wave 2 of the gas-denormalization work (2 commits, read-switch only).What
Flips the two heaviest
/analyticsgas reads off the per-stepworkflow_execution_logs.outputJSONB scan and onto theworkflow_executions.gas_used_weicolumn:getWorkflowGasTotal(summary KPI, current + previous period)getSpendCapData(today's gas vs daily cap)No migration, no schema change, no
@requires-db-prep. Onlylib/analytics/queries.tschanges.Why this is safe to deploy now
The column it reads is already live and verified on prod from wave 1 (#1435):
Because the column is correct, flipping the reads keeps the dashboard numbers stable.
Impact
Removes the logs join, the JSONB parse, and the TOAST detoast from the gas reads. Staging proxy EXPLAIN (heaviest org, 30d): 2,140 ms / ~5.1 GB -> 397 ms / ~162 MB, with the date filter now index-pushed. On prod this eliminates the ~33 GB per-load scan behind the 2026-05-29 RDS CPU incident.
Behavioral note
Gas is now windowed by run-start time (
workflow_executions.started_at) rather than per-step time, because the column is a run-level rollup. This makes gas consistent with every other summary metric; only boundary-straddling runs reattribute, immaterially at dashboard granularity. The per-network breakdown still reads step-level data and is unchanged.Before merging
Confirm the staging deploy of #1434 is healthy (read-switch live,
/analyticsrenders, no new errors). Prod correctness is already established by the wave-1 gate; staging is the runtime sanity check on the read-switch code.