-- Author: fruit.com.cn -- K112 观看记录默认列表的排序索引。 -- 后台按 watched_at DESC, id DESC 倒序翻页,原有索引都以 user_id/drama_id/device_id 开头, -- 不带筛选条件时只能全表扫描再排序;补一条时间索引让翻页直接走索引。 -- watch_history 是分区表,在父表建索引会自动下发到各分区。 BEGIN; CREATE INDEX IF NOT EXISTS idx_watch_history_watched_at ON watch_history (watched_at DESC, id DESC); COMMIT;