Skip to content

feat: Add GIN index on Identity.identifier #5369

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

khvn26
Copy link
Member

@khvn26 khvn26 commented Apr 22, 2025

Thanks for submitting a PR! Please check the boxes below:

  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

This PR improves /api/v1/environments/{environment_api_key}/identities/ when searching through large quantities of identities.

How did you test this code?

Made sure the migration works as expected locally.

The index has been tested in staging and is working in prod for one of the enterprise customers.

@khvn26 khvn26 requested a review from a team as a code owner April 22, 2025 10:22
@khvn26 khvn26 requested review from gagantrivedi and removed request for a team April 22, 2025 10:22
Copy link

vercel bot commented Apr 22, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Apr 22, 2025 10:30am
flagsmith-frontend-preview ⬜️ Ignored (Inspect) Visit Preview Apr 22, 2025 10:30am
flagsmith-frontend-staging ⬜️ Ignored (Inspect) Visit Preview Apr 22, 2025 10:30am

@github-actions github-actions bot added api Issue related to the REST API feature New feature or request labels Apr 22, 2025
Copy link
Contributor

github-actions bot commented Apr 22, 2025

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api-test:pr-5369 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-e2e:pr-5369 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api:pr-5369 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-frontend:pr-5369 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-5369 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-5369 Finished ✅ Results

Copy link
Contributor

github-actions bot commented Apr 22, 2025

Uffizzi Ephemeral Environment deployment-63011

☁️ https://app.uffizzi.com/github.com/Flagsmith/flagsmith/pull/5369

📄 View Application Logs etc.

What is Uffizzi? Learn more!

@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Apr 22, 2025
Copy link

codecov bot commented Apr 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.62%. Comparing base (4b0ae75) to head (ad431e7).
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5369   +/-   ##
=======================================
  Coverage   97.61%   97.62%           
=======================================
  Files        1237     1239    +2     
  Lines       42971    42990   +19     
=======================================
+ Hits        41948    41967   +19     
  Misses       1023     1023           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

indexes = [
UnrestrictedGinIndex(
OpClass(Upper("identifier"), name="gin_trgm_ops"),
name="environments_identity_identifier_gin_idx",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can we shorten the index name to just identifier_gin_idx to avoid having to subclass? It's not immediately clear what UnrestrictedGinIndex means just from the class name. If we do keep that class, could we add a docstring to explain its purpose?

import core.db


_create_index_sql = "CREATE INDEX CONCURRENTLY IF NOT EXISTS environments_identity_identifier_gin_idx ON environments_identity USING GIN (UPPER(identifier) gin_trgm_ops);"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants