insertDeletion looks up recognize_fs_deletions by node_id alone, which no index covers — bulk removals scan the whole table per file
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 82/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- mariadb, php
- 领域
- backend, databases, performance
调研方向
从 lib/Db/FsActionMapper.php 中的 findByNodeId() 和 insertDeletion() 开始,然后检查 lib/Migration/Version011000001Date20251215094821.php 中现有的 unique index。确认查询使用了可用的 storage_id 和 node_id 覆盖范围,或评估 node_id 迁移方案。完成标准是批量删除能够避免为每个文件执行完整的索引扫描;使用 EXPLAIN 和已报告的 files:scan 场景验证查询计划。
由索引模型根据 Issue 内容生成。
描述
FileListener::postDelete() calls FsActionMapper::insertDeletion() for every file under a removed node. insertDeletion() first runs findByNodeId(), i.e. SELECT … FROM oc_recognize_fs_deletions WHERE node_id = ?. The table's only secondary index is the unique (storage_id, node_id) (recognize_fs_del_uniq), which cannot serve a node_id-only predicate, so each call reads the whole index.
On Nextcloud 34.0.2 / Recognize 12.0.2, MariaDB 11.4, with ~512,000 queued rows, an occ files:scan that removed 131,004 files ran at 8–20 files/s and would have taken 1–3 h (EXPLAIN showed type: index, ~539,000 rows per lookup). After ALTER TABLE oc_recognize_fs_deletions ADD INDEX (node_id) the same scan took 5 m 39 s.
Suggested fix: look the row up by (storage_id, node_id), which insertDeletion() already has and the existing unique index covers — or add a node_id index in a migration. The code is the same at the installed tag v12.0.2 (lib/Db/FsActionMapper.php findByNodeId() / insertDeletion(), lib/Migration/Version011000001Date20251215094821.php) and still present on main at dc45cc1.
- 主要语言
- PHP
- 星标
- 701
- 派生
- 70
- 平均合并
- 10 天 22 小时
- 30 天内合并 PR
- 2
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
nextcloud/recognize 的其他 Issue
-
enhancement
难度 5/5 一周以上 新手友好度 35/100
-
bug
难度 3/5 1-2 天 新手友好度 48/100
-
photos: Failed to move selection - No face detection found for file "xxxxx" in face "unassigned"未关闭bug
难度 4/5 3-5 天 新手友好度 48/100
-
enhancement
难度 4/5 3-5 天 新手友好度 35/100
-
bug
难度 4/5 3-5 天 新手友好度 45/100
查看 nextcloud/recognize 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
Automattic/blocks-engine#3618 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 70/100
MagnaCapax/PMSS#1206 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
aimeos/aimeos-typo3#279 ·
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复