- 关键词/剧名预检索加 2000 条上限,避免 IN 列表超限并给出可操作提示 - 新增 created_at 分页索引迁移,避免无条件列表退化为全表排序 - dramaPublished 改为三态,短剧已不存在时不再误报未发布
15 lines
584 B
PL/PgSQL
15 lines
584 B
PL/PgSQL
-- Author: fruit.com.cn
|
|
-- K108 后台收藏/点赞列表按时间倒序的分页索引。
|
|
-- 列表默认 ORDER BY created_at DESC, id DESC,且实体走逻辑删除(deleted = 0),
|
|
-- 原有索引只覆盖 (user_id, created_at) / (device_id, created_at) 前缀,
|
|
-- 不加筛选条件时会退化成全表扫描 + 排序。
|
|
BEGIN;
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_content_like_created
|
|
ON content_like (created_at DESC, id DESC) WHERE deleted = 0;
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_user_favorite_created
|
|
ON user_favorite (created_at DESC, id DESC) WHERE deleted = 0;
|
|
|
|
COMMIT;
|