You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Profile analytics lenses at realistic scale before adding caching #179
#309 already moved analytics onto TanStack Query, bounded the date range and adopted sprint snapshots; #371 fixed single-point charts. The old thirteen-query page inventory and measure-toggle complaint no longer describe the shipping surface. What remains is measuring each current lens and deciding whether server caching or indexes are justified.
Use an isolated disposable workspace with 10,000 to 50,000 issues and capture EXPLAIN (ANALYZE, BUFFERS) for overview, sprints, projects, people and drilldown. Post cold and warm timings before changing queries or caching; any cache must preserve the full authorization scope and freshness contract. The target remains under two seconds for each cold lens at 50,000 issues, with fast cached switching.
Relevant files: packages/core/src/analytics/{overview,sprints,projects,people,drilldown}.ts and apps/web/src/features/analytics/data.ts. A schema change is not assumed before measurement.
#177 adds a date range to the analytics engine, which bounds scopeSeries instead of letting it derive its own bounds from the first issue ever created. That removes a real part of the cost measured here, so the two issues overlap.
Do not implement a date range in this issue. Measure first, post the plans, and let #177 land the bounding. What is left here is the caching, the measure toggle round trip and the index work, which #177 does not touch.
Partly addressed, and the description is now out of date. Re-baselining rather than closing.
What the planning cockpit in #309 changed. The page is no longer a fully dynamic server component running every loader inline. app/(app)/analytics/page.tsx now hydrates one lens and use-analytics-query.ts fetches through TanStack Query against /api/analytics/{lens}, keyed on the whole query. That resolves two of the specific complaints here:
The measure toggle is no longer a server round trip. It changes the query object, which is a client cache hit or one lens fetch, not thirteen queries and a re-render. This was point 3.
scopeSeries is no longer unbounded.packages/core/src/analytics/filter.ts resolves an explicit range and derives bucket granularity from the range width with a MAX_BUCKETS cap, rather than deriving bounds from min(created_at) across all history. The date range work in Add a date range filter to analytics, in the engine and the UI #177 landed and covered this, as this issue anticipated.
The snapshot idea in point 5 was adopted. The sprint lens reads captured facts and snapshots, and formulas() in packages/core/src/analytics/sprints.ts describes the freshness tradeoff it makes.
What is still true. There is still no server-side caching anywhere in the analytics path. No unstable_cache, no revalidate, and nothing keyed on the organisation's sync_id, which was point 2 and is the largest remaining item. Grep for it in apps/web/src/features/analytics/ and packages/core/src/analytics/ and you get nothing.
What is now wrong in the description. The query inventory does not match the code. loadScopeSeries, loadDistributions and loadBreakdown are no longer on the shipping path, and measure-toggle.tsx is not rendered. The cost is now whatever loadAnalyticsOverview, loadSprintAnalytics, loadProjectAnalytics, loadPeopleAnalytics and listAnalyticsDrilldown each cost, and the people and sprint lenses in particular run large hand-written CTEs over issue_activity, cycle_issue_membership and cycle_issue_outcome.
Revised scope. The ask is unchanged and the measurement step is more valuable now than when this was filed, because nobody has profiled the lens queries at all. Capture EXPLAIN (ANALYZE, BUFFERS) per lens on a realistic workspace and post it here, then decide on caching. The definition of done still stands, restated against the new surface: a cold load of each lens on a fifty thousand issue workspace renders in under two seconds, and switching measure or lens is instant.
Files worth reading now instead of the ones listed above: packages/core/src/analytics/overview.ts, people.ts, sprints.ts, projects.ts, drilldown.ts, and apps/web/src/features/analytics/data.ts.
Downgrading to p2 until somebody measures. The revised scope from Aug 15 stands: EXPLAIN (ANALYZE, BUFFERS) per lens on a large workspace first, caching keyed on sync_id second.
changed the title [-]Analytics runs a dozen uncached queries on every page load[/-][+]Profile analytics lenses at realistic scale before adding caching[/+]on Sep 22, 2026
Activity
imshashank commentedon Aug 8, 2026
Scope note against #177.
#177 adds a date range to the analytics engine, which bounds
scopeSeriesinstead of letting it derive its own bounds from the first issue ever created. That removes a real part of the cost measured here, so the two issues overlap.Do not implement a date range in this issue. Measure first, post the plans, and let #177 land the bounding. What is left here is the caching, the measure toggle round trip and the index work, which #177 does not touch.
imshashank commentedon Aug 15, 2026
Partly addressed, and the description is now out of date. Re-baselining rather than closing.
What the planning cockpit in #309 changed. The page is no longer a fully dynamic server component running every loader inline.
app/(app)/analytics/page.tsxnow hydrates one lens anduse-analytics-query.tsfetches through TanStack Query against/api/analytics/{lens}, keyed on the whole query. That resolves two of the specific complaints here:scopeSeriesis no longer unbounded.packages/core/src/analytics/filter.tsresolves an explicit range and derives bucket granularity from the range width with aMAX_BUCKETScap, rather than deriving bounds frommin(created_at)across all history. The date range work in Add a date range filter to analytics, in the engine and the UI #177 landed and covered this, as this issue anticipated.formulas()inpackages/core/src/analytics/sprints.tsdescribes the freshness tradeoff it makes.What is still true. There is still no server-side caching anywhere in the analytics path. No
unstable_cache, norevalidate, and nothing keyed on the organisation'ssync_id, which was point 2 and is the largest remaining item. Grep for it inapps/web/src/features/analytics/andpackages/core/src/analytics/and you get nothing.What is now wrong in the description. The query inventory does not match the code.
loadScopeSeries,loadDistributionsandloadBreakdownare no longer on the shipping path, andmeasure-toggle.tsxis not rendered. The cost is now whateverloadAnalyticsOverview,loadSprintAnalytics,loadProjectAnalytics,loadPeopleAnalyticsandlistAnalyticsDrilldowneach cost, and the people and sprint lenses in particular run large hand-written CTEs overissue_activity,cycle_issue_membershipandcycle_issue_outcome.Revised scope. The ask is unchanged and the measurement step is more valuable now than when this was filed, because nobody has profiled the lens queries at all. Capture
EXPLAIN (ANALYZE, BUFFERS)per lens on a realistic workspace and post it here, then decide on caching. The definition of done still stands, restated against the new surface: a cold load of each lens on a fifty thousand issue workspace renders in under two seconds, and switching measure or lens is instant.Files worth reading now instead of the ones listed above:
packages/core/src/analytics/overview.ts,people.ts,sprints.ts,projects.ts,drilldown.ts, andapps/web/src/features/analytics/data.ts.imshashank commentedon Sep 6, 2026
Downgrading to p2 until somebody measures. The revised scope from Aug 15 stands:
EXPLAIN (ANALYZE, BUFFERS)per lens on a large workspace first, caching keyed onsync_idsecond.[-]Analytics runs a dozen uncached queries on every page load[/-][+]Profile analytics lenses at realistic scale before adding caching[/+]