N+1 Query in `user.member_request_edit`
This causes 41(!!) lazy fetches on every request, adding up to ~120ms.
Sentry Issue: PYCROFT-9D
| Offending Spans | db - SELECT building.site_id AS building_site_i... |
I'm really not sure why this happens. We have precisely 41 buildings, so my guess would be that it's the QuerySelectField. However, this basically only uses a Building.q.all() – so why would sqla lazy-load happen that fetches every building given the building id?
Needs investigation.
relevant frontend endpoint: https://github.com/agdsn/pycroft/blob/968f2adde70f108cc88c3b9f5dc5b7c62f541ba2/web/blueprints/user/init.py#L1138-L1194
It seems that the slow transactions are the POST ones, GET goes through rather quickly.
I think validation might be the culprit, specifically https://github.com/wtforms/wtforms-sqlalchemy/blob/09b3d4745ec98d6d8f769f6794bc217c63d81946/wtforms_sqlalchemy/fields.py#L184-L193 (or the building_query it calls).