coronasafe / care

Care is a Digital Public Good enabling TeleICU & Decentralised Administration of Healthcare Capacity across States.
https://careapi.ohc.network/swagger
MIT License
225 stars 256 forks source link

Fix N+1 queries in `/api/v1/resource/` #1336

Open sainak opened 1 year ago

sainak commented 1 year ago
Sentry Issue: CARE-M5
Transaction Name /api/v1/resource/
Parent Span django.view - resource-request-list
Repeating Spans (0) db - SELECT COUNT(*) AS __count FROM facility_patientregistration WHERE (facility_patientregistration.deleted = %s AND facility_patientregistration.facility_id = %s AND facility_patientregistration.is_active = %s)
db - SELECT COUNT(*) AS __count FROM facility_bed WHERE (facility_bed.deleted = %s AND facility_bed.facility_id = %s)
adityasuthar commented 3 months ago

Hi @sainak can I work on this issue

adityasuthar commented 3 months ago

Parent Span | django.view - resource-request-list

I could not find this Django view in the current version of develop branch. It has been some time since this issue was raised and I think the view class name changed in the meantime. Can you help me finding the view and the query which we need to optimise @sainak @rithviknishad

adityasuthar commented 3 months ago

I found the view ResourceRequestViewSet, working on it.

adityasuthar commented 3 months ago

Hi @sainak @rithviknishad I have raised a pull request at https://github.com/coronasafe/care/pull/2035