Skip to content

Optimize backend database queries in grading workflow #30

@AishaA-cpu

Description

@AishaA-cpu

Problem

Multiple redundant or sequential database queries in grading.py slow down the grading pipeline. Opportunities exist to use advanced SQLAlchemy loading techniques (joinedload, selectinload) for batch-fetching related entities.

Proposal

  • Refactor grading workflow to prefetch assignments, IO test cases, unit tests, static rules, etc. for each submission
  • Use joinedload/selectinload for one-to-many or many-to-one relationships
  • Add appropriate indexes if any filter fields show up in performance analysis

Rationale

  • Reduces DB roundtrips per grading task
  • Lowers contention as grading task throughput increases
  • Simplifies transactional logic and preloading

Acceptance Criteria

  • Grading a submission involves minimal DB queries for related data
  • Queries use batch/optimized loading, evidenced via logs or analysis
  • No unrelated performance regressions

Labels: backend, enhancement, performance

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions