Improve general request performance - #1824
Merged
Merged
Conversation
devmount
marked this pull request as ready for review
September 8, 2026 15:52
davinotdavid
approved these changes
Sep 22, 2026
davinotdavid
left a comment
Contributor
There was a problem hiding this comment.
LGTM!
QA Log
- Code diff
- Manually tested locally and it does seem to improve performance!
devmount
deleted the
bugs/1371-general-page-performance-database-init
branch
September 23, 2026 21:56
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.
What changed?
This is the third (and last for today I promise 😂) PR improving the availability page performance. This one is not scoped to the availability page in particular, but to EVERY single request we made, that needs a database lookup.
We use
get_db()as a per-request dependency, which is fine. But we were calling SQLAlchemy'screate_engine()viaget_engine_and_session()there, causing to open a whole new connection pool without looking for an already existing one.This PR sets a global engine and session (like we do with the redis instance) and checks, if that already exists before creating a new one.
Why?
Prevent long loading times and confusion by UI sitting seconds in an intermediate state.
How to test
http://localhost:5000/*(calendars, external connections, schedule) requests and their timingshttp://localhost:5000/*requests being faster:Limitations and Notes
This is a very heavy impact change. So please double check if I did that right! Existing tests were running fine though.
Applicable Issues
Related to #1371
Screenshots
No UI changes