Severity: Medium
Labels: performance, backend, P2
Location:backend/db/supabase_schema.sql:106-116; query sites backend/routes/learn.py:694-698 (filter user_id, order started_at.desc), backend/routes/profile.py:134
Description
Session history listing and the profile stats count both filter sessions by user_id with no index, so both full-scan (history also sorts by started_at.desc).
Suggested fix
CREATEINDEXIF NOT EXISTS idx_sessions_user_started ON sessions(user_id, started_at DESC);
Acceptance criteria
- The session-history and profile-stats queries use the index (
EXPLAIN); added to schema + migration.
Severity: Medium
Labels: performance, backend, P2
Location:
backend/db/supabase_schema.sql:106-116; query sitesbackend/routes/learn.py:694-698(filteruser_id, orderstarted_at.desc),backend/routes/profile.py:134Description
Session history listing and the profile stats count both filter
sessionsbyuser_idwith no index, so both full-scan (history also sorts bystarted_at.desc).Suggested fix
Acceptance criteria
EXPLAIN); added to schema + migration.