From 4e94d2813140c87c5447ccc3e26dc4fe6b651030 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Fri, 30 Oct 2026 10:47:44 -0700 Subject: [PATCH 1/2] docs(billing): scope the usage_log workspace index note to created_at windows --- apps/sim/lib/billing/core/usage-analytics-queries.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/sim/lib/billing/core/usage-analytics-queries.ts b/apps/sim/lib/billing/core/usage-analytics-queries.ts index 8e075e18a77..fa02f0922a2 100644 --- a/apps/sim/lib/billing/core/usage-analytics-queries.ts +++ b/apps/sim/lib/billing/core/usage-analytics-queries.ts @@ -27,8 +27,10 @@ import type { DbClient } from '@/lib/db/types' * and the member/source breakdowns are index-only. `workspace_id`, `workflow_id`, * `description`, `metadata`, and `execution_id` are NOT in it, so the remaining * reads heap-fetch per row — which is why they are issued only for the dimension - * actually being viewed. A read narrowed to one workspace runs on - * `usage_log_workspace_created_at_cost_idx` instead, which also covers `workflow_id`. + * actually being viewed. A read narrowed to one workspace over a `created_at` window + * (a range or a reporting period) is index-only on + * `usage_log_workspace_created_at_cost_idx` instead, which also covers `workflow_id`; + * a Stripe-period drill-down matches the period stamps, which that index does not carry. */ export interface UsageTimeSeriesRow { From c3f498f4c1c12c521bef8635864311d458878ab7 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Fri, 30 Oct 2026 11:09:31 -0700 Subject: [PATCH 2/2] docs(billing): limit the workspace index note to the reads it covers --- apps/sim/lib/billing/core/usage-analytics-queries.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/sim/lib/billing/core/usage-analytics-queries.ts b/apps/sim/lib/billing/core/usage-analytics-queries.ts index fa02f0922a2..9ca62ba8fa7 100644 --- a/apps/sim/lib/billing/core/usage-analytics-queries.ts +++ b/apps/sim/lib/billing/core/usage-analytics-queries.ts @@ -27,10 +27,11 @@ import type { DbClient } from '@/lib/db/types' * and the member/source breakdowns are index-only. `workspace_id`, `workflow_id`, * `description`, `metadata`, and `execution_id` are NOT in it, so the remaining * reads heap-fetch per row — which is why they are issued only for the dimension - * actually being viewed. A read narrowed to one workspace over a `created_at` window - * (a range or a reporting period) is index-only on - * `usage_log_workspace_created_at_cost_idx` instead, which also covers `workflow_id`; - * a Stripe-period drill-down matches the period stamps, which that index does not carry. + * actually being viewed. Narrowed to one workspace over a `created_at` window (a range + * or a reporting period), the totals, the series, and the member, source and workflow + * breakdowns are index-only on `usage_log_workspace_created_at_cost_idx` instead, which + * also covers `workspace_id` and `workflow_id`; the model breakdowns still heap-fetch, + * and a Stripe-period drill-down matches the period stamps, which that index lacks. */ export interface UsageTimeSeriesRow {