Files
gongxue-base/supabase/migrations/202606210013_learning_stats_history.sql
2026-06-28 23:44:52 +08:00

19 lines
877 B
SQL

create index if not exists idx_practice_sessions_user_started
on public.practice_sessions(tenant_id, user_id, started_at desc);
create index if not exists idx_practice_sessions_user_finished
on public.practice_sessions(tenant_id, user_id, finished_at desc)
where finished_at is not null;
create index if not exists idx_answer_records_user_answered
on public.answer_records(tenant_id, user_id, answered_at desc);
create index if not exists idx_answer_records_session_latest
on public.answer_records(tenant_id, user_id, practice_session_id, question_id, answered_at desc);
create index if not exists idx_wrong_questions_user_review
on public.wrong_questions(tenant_id, user_id, resolved_at, last_wrong_at desc, wrong_count desc);
create index if not exists idx_favorite_questions_user_created
on public.favorite_questions(tenant_id, user_id, created_at desc);