Add partial index on tools for active_subscription filtering#28
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Add partial index on tools for active_subscription filtering#28devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
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 <alecvdpoel@pm.me>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
Summary
Adds a Supabase migration that creates a partial B-tree index on
tools(billing_cycle) WHERE active_subscription = true.Analysis performed: The
active_subscriptioncolumn is used as a filter predicate in three client-side computed selectors (totalMonthlyCost,totalAnnualCost,renewingWithin30Days), all of which filter foractive_subscription === trueand then branch onbilling_cycle. The partial index targets this pattern and keeps the index footprint small by only including rows with active subscriptions.bill_daywas intentionally not indexed — it is only consumed by thenextRenewalDate()date computation utility and never appears as a filter, join, or sort predicate.Important caveat: Currently,
fetchToolsloads all rows viaselect('*').order('name')and all filtering happens client-side in JS. This index is forward-looking — it won't be exercised until those selectors are refactored into server-side queries (e.g..eq('active_subscription', true)).Review & Testing Checklist for Human
active_subscriptionorbilling_cycleserver-side. If you don't plan to push these filters to the DB, this index adds write overhead with no read benefit.ON tools(billing_cycle) WHERE active_subscription = true) matches the query patterns you intend to support. If you'd rather filter/sort by a different column (e.g.cost,renewal_date), the indexed column should change.bill_dayis acceptable for your use case.Notes
CREATE INDEX IF NOT EXISTS, so it is idempotent and safe to re-run.20260415_...) follows the existing naming convention insupabase/migrations/.Link to Devin session: https://app.devin.ai/sessions/c463c41903f2427ebc930a895dc4e7ad
Requested by: @alecvdp