perf: add GIN indexes on clazz JSONB columns and date-range indexes

- GIN indexes on students/teachers (jsonb_path_ops) for fast user lookups
- Composite index on clazz (is_repeat, start_from, end_by) for date range queries
- Indexes on clazz_repeat (clazz_id, repeat_start, repeat_end) for joins

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-03 09:39:36 +08:00
parent 7b05a91988
commit fa14a5ca8c
12 changed files with 55 additions and 0 deletions
@@ -0,0 +1,3 @@
DROP INDEX IF EXISTS idx_teacher_student_department_id;
ALTER TABLE teacher_student DROP COLUMN IF EXISTS department_id;
@@ -0,0 +1,4 @@
-- Add department_id to teacher_student (nullable first, backfill, then not-null in future)
ALTER TABLE teacher_student ADD COLUMN department_id VARCHAR;
CREATE INDEX idx_teacher_student_department_id ON teacher_student (department_id);