cvat
cvat copied to clipboard
Optimize DB requests in project list, job list, and other endpoints
Motivation and context
- Added an option to use the organization instance from the object in question, if provided (many viewsets prefetch this)
- Removed
.first()
calls, leading to extra db requests for projects - Added prefetch for source and target storages of jobs
- Optimized calls to related manifests in cloudstorages api (however, manifests should be either moved to a separate endpoint or should be limited in maximum number per CS)
- Optimized unnecessary DB requests to related models in IAM requests
All this primarily affected GET /api/projects and GET /api/jobs, but other endpoints also benefited from this a little bit.
Examples: 4 projects, > 100 tasks, > 100 jobs
Before:
After:
How has this been tested?
Checklist
- [ ] I submit my changes into the
develop
branch - [ ] I have created a changelog fragment
- [ ] I have updated the documentation accordingly
- [ ] I have added tests to cover my changes
- [ ] I have linked related issues (see GitHub docs)
- [ ] I have increased versions of npm packages if it is necessary (cvat-canvas, cvat-core, cvat-data and cvat-ui)
License
- [ ] I submit my code changes under the same MIT License that covers the project. Feel free to contact the maintainers if that's a concern.
Summary by CodeRabbit
-
New Features
- Enhanced performance of data retrieval in views by optimizing related fields in the JobViewSet.
- Improved handling of organization data in permissions, ensuring more robust checks and reducing unnecessary database queries.
-
Bug Fixes
- Refined output of serialized data to include only valid task subsets and handle dimensions correctly.
-
Documentation
- Updates made to improve clarity on serialized responses and organization permission handling.