stack/apps/backend/scripts
Bilal Godil 81c84289b8 perf(platform-analytics): cut ClickHouse query peak memory
Reduce the worst-case concurrent ClickHouse memory of the internal
platform-analytics route (all 17 CH queries fire in one Promise.all on
the shared admin user, against a 9 GB per-user cap).

- Use sipHash64(user_id) as the distinct key in the uniqExact/uniqExactIf
  aggregates (dauSeries, sparkByProject, mauProjects, activeByProject).
  Exact at this scale (64-bit, negligible collision prob over 1M users),
  verified byte-identical; -40% to -61% peak memory per query.
- Sample the new/retained/reactivated activity split at 1-in-4 users
  (consistent cityHash bucket on both subqueries, counts scaled x4). The
  split's window function + all-history scan made it the heaviest query
  (~1.3 GiB at 1M users / 50M events); sampling cuts it ~78% for a ~0.4%
  mean error. Dashboard chart now notes it is a sampled estimate.

Adds the benchmark/optimization harnesses used to validate these changes
(seed isolated bench_pa DBs, measure peak memory, verify result equality).
2026-06-19 10:54:37 -07:00
..
verify-data-integrity feat(hexclave): PR 3 — native @hexclave/* source rename + delete dual-publish wiring (#1482) 2026-05-29 15:21:59 -07:00
backfill-internal-free-plans.ts feat(hexclave): PR 3 — native @hexclave/* source rename + delete dual-publish wiring (#1482) 2026-05-29 15:21:59 -07:00
benchmark-internal-metrics.ts feat(hexclave): PR 3 — native @hexclave/* source rename + delete dual-publish wiring (#1482) 2026-05-29 15:21:59 -07:00
benchmark-platform-analytics.ts perf(platform-analytics): cut ClickHouse query peak memory 2026-06-19 10:54:37 -07:00
bulldozer-payments-init.ts Make Bulldozer SQL statements deterministic 2026-04-18 16:43:26 -07:00
clickhouse-migrations.ts feat(analytics): add route analytics heatmaps (#1520) 2026-06-15 12:06:16 -07:00
db-migrations.ts [Feat] new scripts on migrate/seed/init run for internal (#1421) 2026-05-12 16:05:45 -07:00
db-migrations.tsdown.config.ts Fix Docker build 2026-03-09 10:49:42 -07:00
generate-keys.ts Split backend and dashboard (#83) 2024-06-18 15:49:31 +02:00
generate-migration-imports.ts feat(hexclave): PR 3 — native @hexclave/* source rename + delete dual-publish wiring (#1482) 2026-05-29 15:21:59 -07:00
generate-openapi-fumadocs.ts feat(hexclave): PR 3 — native @hexclave/* source rename + delete dual-publish wiring (#1482) 2026-05-29 15:21:59 -07:00
generate-private-sign-up-risk-engine.ts feat(hexclave): PR 3 — native @hexclave/* source rename + delete dual-publish wiring (#1482) 2026-05-29 15:21:59 -07:00
generate-route-info.ts fixes? 2025-12-12 17:29:57 -08:00
optimize-platform-analytics.ts perf(platform-analytics): cut ClickHouse query peak memory 2026-06-19 10:54:37 -07:00
optimize-split.ts perf(platform-analytics): cut ClickHouse query peak memory 2026-06-19 10:54:37 -07:00
regen-internal-subscriptions-to-latest.ts feat(hexclave): PR 3 — native @hexclave/* source rename + delete dual-publish wiring (#1482) 2026-05-29 15:21:59 -07:00
run-bulldozer-studio.ts feat(hexclave): PR 3 — native @hexclave/* source rename + delete dual-publish wiring (#1482) 2026-05-29 15:21:59 -07:00
run-cron-jobs.ts feat(hexclave): PR 3 — native @hexclave/* source rename + delete dual-publish wiring (#1482) 2026-05-29 15:21:59 -07:00
run-email-queue.ts feat(hexclave): PR 3 — native @hexclave/* source rename + delete dual-publish wiring (#1482) 2026-05-29 15:21:59 -07:00