Severity: Medium
Labels: performance, backend, P2
Location:backend/db/supabase_schema.sql:129-139 (quiz_attempts), :197-204 (study_guides); query sites backend/routes/study_guide.py:119-123 (filter user_id, order generated_at.desc), :185-192 (filter user_id+course_id+exam_id)
Description
study_guides cached-guide listing and the cache-hit lookup full-scan (no index at all). quiz_attempts has no index on user_id/concept_node_id, which the achievement-count and history aggregations scan.
Suggested fix
CREATEINDEXIF NOT EXISTS idx_study_guides_user ON study_guides(user_id, generated_at DESC);
CREATEINDEXIF NOT EXISTS idx_study_guides_lookup ON study_guides(user_id, course_id, exam_id);
CREATEINDEXIF NOT EXISTS idx_quiz_attempts_user ON quiz_attempts(user_id);
Acceptance criteria
- The study-guide list/lookup and quiz-attempt aggregations use indexes; added to schema + migration.
Severity: Medium
Labels: performance, backend, P2
Location:
backend/db/supabase_schema.sql:129-139(quiz_attempts),:197-204(study_guides); query sitesbackend/routes/study_guide.py:119-123(filteruser_id, ordergenerated_at.desc),:185-192(filteruser_id+course_id+exam_id)Description
study_guidescached-guide listing and the cache-hit lookup full-scan (no index at all).quiz_attemptshas no index onuser_id/concept_node_id, which the achievement-count and history aggregations scan.Suggested fix
Acceptance criteria