Skip to content

Improve general request performance - #1824

Merged
devmount merged 2 commits into
mainfrom
bugs/1371-general-page-performance-database-init
Sep 23, 2026
Merged

devmount merged 2 commits into
mainfrom
bugs/1371-general-page-performance-database-init

Conversation

@devmount

@devmount devmount commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

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's create_engine() via get_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

  1. Don't check out this branch yet
  2. Open the availability page and the web console with the network tab
  3. Clear the network tab and hit CTRL+F5
  4. See the different http://localhost:5000/* (calendars, external connections, schedule) requests and their timings
    image
  5. Now check out this branch and repeat steps 2-4
  6. See the http://localhost:5000/* requests being faster:
    image

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

@devmount
devmount marked this pull request as ready for review September 8, 2026 15:52

@davinotdavid davinotdavid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

QA Log

  • Code diff
  • Manually tested locally and it does seem to improve performance!

@devmount
devmount merged commit 5ecf0ec into main Sep 23, 2026
10 checks passed
@devmount
devmount deleted the bugs/1371-general-page-performance-database-init branch September 23, 2026 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants