[Bug]: Files "Recent" view takes 13–21 s: `mtime OR upload_time` across two tables prevents index use
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 30/100
調査の方向性
Start from the Recent query in the report: its mtime OR upload_time condition spans oc_filecache and oc_filecache_extended, which stops MariaDB using fs_mtime or fce_utime_idx. Run EXPLAIN on the query and on the UNION-of-candidate-IDs variant described in the issue, then compare. Done when the Recent query uses the indexes, returns the same rows, and finishes well under a second on a large filecache.
索引モデルが issue の本文から書いたものです。
説明
⚠️ This issue respects the following points: ⚠️
- This is not a troubleshooting question, general support matter, or webserver/proxy problem, but likely a bug (if unsure, ask the Community Help Forum).
- This issue is not already reported on Github OR solved at the Community Help Forum (I've searched!).
- I'm using a maintained major version of Nextcloud Server and tested against the latest patch level. (Supported major versions and current patch levels).
- I agree to follow Nextcloud's Code of Conduct.
- I've tried my best to provide clear reproduction steps that someone unfamiliar with this bug could use to reproduce it.
Bug description
Since upload_time was added to recent files (#58327), the query behind the Files "Recent" view combines file.mtime > X OR fe.upload_time > X. The two columns are in different tables (oc_filecache, oc_filecache_extended), so MariaDB cannot use fs_mtime or fce_utime_idx. It falls back to a range scan over all filecache rows of the user's storages.
On this instance, 142 rows match on mtime and 0 on upload_time, but every call examines ~770,000 rows and takes 13–21 s.
Query from the slow log (shortened select list):
SELECT `file`.`fileid`, ... FROM `oc_filecache` `file`
LEFT JOIN `oc_filecache_extended` `fe` ON `file`.`fileid` = `fe`.`fileid`
LEFT JOIN `oc_vcategory_to_object` `tagmap` ON `file`.`fileid` = `tagmap`.`objid`
LEFT JOIN `oc_files_metadata` `meta` ON `file`.`fileid` = `meta`.`file_id`
LEFT JOIN `oc_vcategory` `tag` ON (`tagmap`.`categoryid` = `tag`.`id`) AND (`tag`.`type` = 'files') AND (`tag`.`uid` = '<user>')
WHERE ((`mimetype` <> '2') OR (`size` = 0))
AND ((`mtime` > 1794051606) OR (`upload_time` > 1794051606))
AND (((`storage` = 3) AND ((`path` = 'files') OR (`path` LIKE 'files/%'))) OR (`storage` IN (12, 22)))
ORDER BY GREATEST(`file`.`mtime`, COALESCE(fe.upload_time, 0)) desc LIMIT 100;
# Query_time: 20.915799 Rows_sent: 69 Rows_examined: 769951
# explain: 1 SIMPLE file range fs_storage_mimepart ... rows 851837 r_rows 767816 ... Using index condition; Using where; Using temporary; Using filesort
Selecting the candidate IDs first through both indexes returns the same rows in 0.19 s:
SELECT ... FROM (
SELECT fileid FROM oc_filecache WHERE mtime > 1794051606
UNION
SELECT fileid FROM oc_filecache_extended WHERE upload_time > 1794051606
) u
JOIN oc_filecache file ON file.fileid = u.fileid
LEFT JOIN oc_filecache_extended fe ON ...
WHERE <same storage/mimetype conditions>
ORDER BY ... LIMIT 100;
A WHERE file.fileid IN (... UNION ...) variant does not help: MariaDB turns it into a dependent subquery and scans again (30 s).
Steps to reproduce
- Have a user with large storages in the filecache (here: home + two local external storages, ~770k rows).
- Open Files → Recent.
Expected behavior
The query uses the mtime / upload_time indexes and returns in well under a second.
Actual behavior
Full range scan over all filecache rows of the user's storages, 13–21 s per call.
Nextcloud Server version
35
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.4
Web server
Apache (supported)
Database engine version
MariaDB
Is this bug present after an update or on a fresh install?
None
Are you using the Nextcloud Server Encryption module?
Encryption is Disabled
What user-backends are you using?
- Default user-backend (database)
- LDAP/ Active Directory
- SSO - SAML
- Other
Configuration report
No response
List of activated Apps
No response
Nextcloud Signing status
No errors have been found.
Nextcloud Logs
No log entries; the query shows up only in the MariaDB slow query log (quoted above).
Additional info
Nextcloud 35.0.3, MariaDB 11.8.6, PHP 8.4.28, Debian 13 (aarch64). Validated and reproduced on a live Nextcloud instance; timings above are from that instance.
Assisted by ClaudeCode:claude-opus-5-5
- 主要言語
- PHP
- スター
- 37.6k
- フォーク
- 5.4k
- 平均マージ
- 1日 13時間
- マージ済み PR(30日)
- 623
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nextcloud/server のほかの issue
-
0. Needs triage 35-feedback bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
34-feedback
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: GET /js/../<anything> returns 500 (NotPermittedException from JsController::getJs) instead of 404対応中かも @lazerg が 7 日前に担当しました。 オープン35-feedback
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: Dashboard widgets registered via OCA.Dashboard.register() sometimes never mount (spinner forever) – Vue 3 non-deep `callbacks` watcher race対応中かも @lazerg が 7 日前に担当しました。 オープン35-feedback
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
nextcloud/server の issue をすべて見る
似ている issue
-
area: tests area: user refactoring
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
nplhse/collaborative-ivena-statistics#1845 ·
メンテナーはふだん 1 日以内に返信
-
[Sync EN] filesystem: document the ValueError of fgets(), file_get_contents(), and touch() (#6167)オープンsync-en
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
sync-en
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 2 日以内に返信
-
Перевод устарел
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
-
Documentation Feature: Events / Calendar
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信