-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix(cohorts): Drop redundant cohortcalculationhistory indexes #42860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(cohorts): Drop redundant cohortcalculationhistory indexes #42860
Conversation
Migration SQL ChangesHey 👋, we've detected some migrations on this PR. Here's the SQL output for each migration, make sure they make sense:
|
🔍 Migration Risk AnalysisWe've analyzed your migrations for potential risks. Summary: 1 Safe | 0 Needs Review | 0 Blocked ✅ SafeBrief or no lock, backwards compatible Last updated: 2025-12-08 21:36 UTC (b50450e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR drops redundant database indexes on the posthog_cohortcalculationhistory table to reduce database overhead and improve performance. The indexes being removed are covered by existing composite indexes.
Key Changes:
- Drops single-column index on
cohort_id(covered by composite index oncohort_id, started_at DESC) - Drops single-column index on
team_id(covered by composite indexes onteam_id, cohort_idandteam_id, started_at)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| posthog/migrations/0936_remove_redundant_cohortcalculationhistory_indexes.py | Migration to drop two redundant indexes using DROP INDEX CONCURRENTLY for non-blocking database operation |
| posthog/migrations/max_migration.txt | Updated to track the latest migration number |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
posthog/migrations/0936_remove_redundant_cohortcalculationhistory_indexes.py
Outdated
Show resolved
Hide resolved
posthog/migrations/0936_remove_redundant_cohortcalculationhistory_indexes.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 files reviewed, no comments
Both of these are not neccessary due to composite indexes that cover the same space
Seems unnecessary, but what if?
8fc868c to
268cc6f
Compare
This change drops some unused/redundant indexes on
posthog_cohortcalculationhistory.We currently have:
posthog_cohortcalculationhistory_cohort_id_e7c02b55indexescohort_id, but so does the composite indexposthog_coh_cohort__cbac1b_idx.posthog_cohortcalculationhistory_team_id_beba9c96indexesteam_id, but so do the composite indexesposthog_coh_team_id_0ba00c_idxandposthog_coh_team_id_762cc7_idx.This change drops
posthog_cohortcalculationhistory_cohort_id_e7c02b55,posthog_cohortcalculationhistory_team_id_beba9c96.