-- 新增覆盖索引用于深度分页优化（两阶段延迟 Join）
-- 问题：深度分页（page >= 50）需要 OFFSET 数千行，SELECT * 读取大量宽行数据（~2KB/行）
-- 方案：Phase 1 仅扫描覆盖索引获取 ID，Phase 2 用 ID 批量回表取完整数据
-- 预期：page 500 从 5.6s → <500ms
--
-- 生产环境建议手动执行带 CONCURRENTLY 的版本避免锁表：
-- CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_iot_card_standalone_shop_created_id
--   ON tb_iot_card (shop_id, created_at DESC, id)
--   WHERE deleted_at IS NULL AND is_standalone = true;

CREATE INDEX IF NOT EXISTS idx_iot_card_standalone_shop_created_id
ON tb_iot_card (shop_id, created_at DESC, id)
WHERE deleted_at IS NULL AND is_standalone = true;

ANALYZE tb_iot_card;
