-- GET /api/training-units: Keyset über (planned_date, planned_time_start NULLS LAST per Sort, id) -- Ersetzt den reinen Datum/Uhrzeit-Teilindex 059 durch zwei Richtungen mit Tie-Break id. DROP INDEX IF EXISTS idx_training_units_scheduled_order; CREATE INDEX IF NOT EXISTS idx_training_units_list_keyset_desc ON training_units ( planned_date DESC, (planned_time_start IS NULL) ASC, planned_time_start DESC NULLS LAST, id DESC ) WHERE framework_slot_id IS NULL; CREATE INDEX IF NOT EXISTS idx_training_units_list_keyset_asc ON training_units ( planned_date ASC, (planned_time_start IS NULL) ASC, planned_time_start ASC NULLS LAST, id ASC ) WHERE framework_slot_id IS NULL;