Skip to content

[IA-4458] fix setuper slow again#2834

Open
Crebert08 wants to merge 2 commits intodevelopfrom
IA-4458-fix-setuper-slow-again
Open

[IA-4458] fix setuper slow again#2834
Crebert08 wants to merge 2 commits intodevelopfrom
IA-4458-fix-setuper-slow-again

Conversation

@Crebert08
Copy link
Copy Markdown
Contributor

@Crebert08 Crebert08 commented Mar 18, 2026

What problem is this PR solving?

The setuper was slow. This PR is about proposing a fix for that.

Related JIRA tickets

IA-4458

Changes

  • Implemented the serializer that supports fields parameter in iaso/api/org_units.py
  • sent the patch request with 'id' as a field parameter

How to test

Run the setuper: /home/crebert/Desktop/iaso/setuper/README.md
The duplicates for the patch requests went from 101 to 6
Total number of queries went from 118 to 28
Response weight went from ~80Ko to ~10 o

Print screen / video

Notes

Things that the reviewers should know:

  • known bugs that are out of the scope of the PR
  • other trade-offs that were made
  • does the PR depends on a PR in bluesquare-components?
  • should the PR be merged into another PR?

Doc

Tell us where the doc can be found (docs folder, wiki, in the code...).

@Crebert08 Crebert08 requested a review from butofleury March 18, 2026 14:38
@Crebert08 Crebert08 marked this pull request as draft March 18, 2026 14:38
@Crebert08 Crebert08 requested a review from tdethier March 18, 2026 14:45
@Crebert08 Crebert08 marked this pull request as ready for review March 18, 2026 14:54
@quang-le quang-le added the release Should be released in production at next deploy label Mar 19, 2026
Copy link
Copy Markdown
Member

@tdethier tdethier left a comment

Choose a reason for hiding this comment

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

So, I ran the setuper locally with and without this PR in order to compare results - there was a slight improvement:

Without this PR:

Image

With this PR:

Image

But there are still a lot of duplicated queries in multiple calls, which is something we can probably improve. When looking at random times, I still see very long queries, such as

  • updating the default picture of an org unit
Image
  • other random calls (sorry I did not check what the setuper was doing at that moment)
Image Image Image Image
  • this one is way too long, 2 seconds for a GET on org unit types is crazy:
Image
  • PATCH on that endpoint is long as well:
Image

forms and sync might be too old/difficult to fix, but I'm hoping to improve at least org unit types and profiles

Comment on lines +773 to +779
requested_fields = request.query_params.get("fields")
if requested_fields:
serializer = OrgUnitSearchSerializer(
org_unit, fields=requested_fields.split(","), context={"request": request}
)
return Response(serializer.data)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you please add a unit test to make sure that you receive only the requested fields as a result of a PATCH?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release Should be released in production at next deploy

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants