feat: add index to avoid performance degradation #1606
Merged
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.
Purpose of the Pull Request
This pull request introduces database indexing improvements which significantly enhance performance in the production environment.
How to Test
To validate the changes:
Ensure the development environment is set up and running.
Apply the database migrations included in this PR.
Run the application and perform typical operations that involve querying the indexed data.
Use profiling tools (e.g., python -m cProfile) to measure the performance before and after applying the index.
Expected outcomes:
Queries involving the indexed fields should execute faster.
Profiling results should show a decrease in query execution time.
Have You Tested This PR?
Yes, I have tested the latest commit on this PR.
Before applying the index
After applying the index
Related Issues or PRs
Is Your PR Over 500 Lines of Code?
No, this PR includes under 500 lines of code.
Additional Context
The performance improvement was observed in our production environment after deploying these changes. The indexing strategy was carefully designed to optimize frequently used queries without impacting write performance.