[SQL] Person statistics in "My students" take very long #150
Labels
No labels
Security
TeX
auto-update
board
done
board
ready
board
todo
check
delete-eslint-rc-js
check
update-builddeps-package-json
check
update-eslint-rc-js
check
update-gitignore
check
update-merge-request-template
check
update-prettier-ignore
check
update-pyproject-toml
check
update-renovate-json
check
update-tox-ini
part
backend
part
ci
part
docs
part
frontend
part
i18n
part
non-technical
part
packaging
prio
1
prio
2
prio
3
release-mr-5.x
size
large
size
medium
size
small
source
customer
source
customer::fsmw
source
customer::fss
source
customer::teckids
source
downstream
type
breaking
type
bug
type
feature
type
refactoring
workflow
blocked
workflow
confirmed
workflow
current-todo
workflow
discussing
workflow
new-app
workflow
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
aleksis/AlekSIS-App-Alsijil#150
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This query takes 18020 ms (example in production).
changed the description
Example plan form production:
No lengthy analysis done until now, but a few low-hanging fruits that might help:
idout of theDISTINCTqueryAdditionally, a hint from credativ DB team:
(U11."group_id" = 5856 OR U13."to_group_id" = 5856 OR U15."group_id" = 5856 OR U17."to_group_id" = 5856 OR U19."group_id" = 5856 OR U21."to_group_id" = 5856)should probably be part of theLEFT OUTER JOINconditions further up (same forschool_term)https://explain.depesz.com/s/qFim
https://docs.djangoproject.com/en/3.1/ref/models/querysets/#filteredrelation-objects might be of some help
https://docs.djangoproject.com/en/3.1/ref/models/querysets/#django.db.models.query.QuerySet.only as well
Moving the most of the
WHEREclause into the joins gives us an improvement of (only) a few seconds:https://explain.depesz.com/s/6ziN
The query is executed in https://edugit.org/AlekSIS/official/AlekSIS-App-Alsijil/-/blob/master/aleksis/apps/alsijil/model_extensions.py#L382.
assigned to @hansegucker
created merge request !552 to address this issue
mentioned in merge request !552
mentioned in commit
f6a1b81731For documentation, here's the query after !552, and its plan:
Execution time went down from ~24,000ms to ~40ms.