-
Notifications
You must be signed in to change notification settings - Fork 19.5k
chore: optimize SQL queries that perform partial full table scans #24786
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
Conversation
d21c320 to
ffd6fd1
Compare
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 optimizes SQL queries by addressing partial full table scan issues through database indexing improvements and caching strategies to reduce database load. The changes focus on preventing performance bottlenecks caused by frequent database operations.
- Added a database index on
workflow_run_idcolumn for theworkflow_app_logstable - Implemented Redis-based caching for provider last used timestamps to reduce database update frequency
- Optimized database deletion operations by using compound indexes and disabling session synchronization
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
api/models/workflow.py |
Added database index on workflow_run_id column to optimize query performance |
api/migrations/versions/2025_08_29_1534-b95962a3885c_add_workflow_app_log_run_id_index.py |
Database migration to create the new workflow run ID index |
api/events/event_handlers/update_provider_when_message_created.py |
Implemented Redis caching for provider updates with time-window based updates |
api/core/rag/index_processor/processor/parent_child_index_processor.py |
Optimized deletion queries by using compound indexes and disabling session synchronization |
api/core/app/apps/advanced_chat/generate_task_pipeline.py |
Removed message event emission to reduce database operations |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
api/migrations/versions/2025_08_29_1534-b95962a3885c_add_workflow_app_log_run_id_index.py
Show resolved
Hide resolved
api/events/event_handlers/update_provider_when_message_created.py
Outdated
Show resolved
Hide resolved
api/events/event_handlers/update_provider_when_message_created.py
Outdated
Show resolved
Hide resolved
api/events/event_handlers/update_provider_when_message_created.py
Outdated
Show resolved
Hide resolved
api/events/event_handlers/update_provider_when_message_created.py
Outdated
Show resolved
Hide resolved
QuantumGhost
left a comment
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.
LGTM
Summary
optimize SQL queries that perform partial full table scans
Fix #24784
Checklist
dev/reformat(backend) andcd web && npx lint-staged(frontend) to appease the lint gods