Flagsmith / Flagsmith/flagsmith

UUID-based identities search is very slow

Open
#8,528 0 comments 0 reactions 0 assignees View on GitHub
api performance
Dominant language
Python
Stars
6.6k
Forks
567
Avg merge
1d 13h
Merged PRs (30d)
121

Description

> [!WARNING]
> This issue aims to resolve a hindering performance issue.

A GIN index for _identities_ exists in production, and it causes severe database degradation under certain circumstances observed in production, e.g. searching for an UUID identifier.

Timeline for context:

1. A GIN index `identity_identifier_idx` was added to `environments_identity.identifier`.
#5369
2. The migration was reverted [before it reached production](https://github.com/Flagsmith/flagsmith/pull/5453).
#5481
3. Regardless, the index exists. It might have been added **manually**.

## Acceptance criteria

- [ ] The GIN index is deleted or repurposed so it doesn't derail a query plan.
- [ ] The original need for this index is revisited and catered for — possibly in a new issue.

Contributor guide

Open the contributing guide

Research direction

Trace the schema and migration history for the environments_identity.identifier GIN index named identity_identifier_idx, then reproduce the UUID search while inspecting the database query plan. Done means the index is removed or repurposed without degrading searches, and the original indexing need is addressed or clearly separated into follow-up work.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.