Optimize search#634
Merged
Mastermind-U merged 17 commits intomainfrom Jul 24, 2025
Merged
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR optimizes search performance in the LDAP protocol implementation by improving database queries and fixing spelling errors. The changes focus on replacing inefficient array-based operations with indexed depth column queries, optimizing join strategies, and adding database indexes.
- Replaces array cardinality operations with indexed depth column for better query performance
- Optimizes join strategies by changing from joined loads to select-in loads and adding explicit joins
- Adds comprehensive database indexes for frequently queried fields and implements query explain functionality
Reviewed Changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| app/multidirectory.py | Fixes spelling error in module docstring |
| app/models.py | Adds database index to depth column for optimized queries |
| app/ldap_protocol/utils/helpers.py | Adds PostgreSQL EXPLAIN functionality for query analysis |
| app/ldap_protocol/ldap_requests/search.py | Optimizes query joins and pagination logic |
| app/ldap_protocol/filter_interpreter.py | Refactors filter conditions and fixes case sensitivity |
| app/ldap_protocol/dependency.py | Fixes spelling error in module docstring |
| app/ioc.py | Refactors dependency injection provider methods and fixes docstring |
| app/config.py | Removes pool_pre_ping configuration for performance |
| app/alembic/versions/a7971f00ba4d_index_single_level.py | Adds comprehensive database indexes for performance optimization |
| app/alembic/versions/275222846605_initial_ldap_schema.py | Removes unnecessary pg_trgm extension cleanup |
| app/main.py | Adds new module initialization file |
|
|
||
| from ldap_protocol.utils.helpers import explain_query | ||
|
|
||
| await explain_query(query, session) |
There was a problem hiding this comment.
The explain_query call appears to be debug code that should not be in production. Consider removing this or wrapping it in a debug flag check.
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.
No description provided.