From 5d4e15deaf0e5005d741a00638c29d5fab24f894 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 15 Apr 2026 03:04:41 +0000 Subject: [PATCH] Add partial index on tools for active_subscription filtering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a partial index on tools(billing_cycle) WHERE active_subscription = true. The active_subscription column is used as a filter predicate in multiple computed selectors (totalMonthlyCost, totalAnnualCost, renewingWithin30Days). This partial index keeps the footprint small while targeting the common query pattern of filtering for tools with an active subscription. No index added for bill_day — it is only used in the nextRenewalDate() date computation utility and never appears as a filter, join, or sort predicate in any query. Co-Authored-By: alecvdpoel --- .../20260415_add_index_active_subscription_to_tools.sql | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 supabase/migrations/20260415_add_index_active_subscription_to_tools.sql diff --git a/supabase/migrations/20260415_add_index_active_subscription_to_tools.sql b/supabase/migrations/20260415_add_index_active_subscription_to_tools.sql new file mode 100644 index 0000000..64185d0 --- /dev/null +++ b/supabase/migrations/20260415_add_index_active_subscription_to_tools.sql @@ -0,0 +1,9 @@ +-- Index for active_subscription on tools table. +-- The active_subscription column is used as a filter predicate in multiple +-- computed selectors (totalMonthlyCost, totalAnnualCost, renewingWithin30Days). +-- A partial index keeps the index small and targets the common query pattern +-- of filtering for tools with an active subscription. + +create index if not exists idx_tools_active_subscription + on tools (billing_cycle) + where active_subscription = true;