Skip to content

Perf: Optimize pages loading (Filecache path like approach) - #2549

Merged
max-nextcloud merged 3 commits into
mainfrom
feature/optimize-pages-loading-v2
Jun 30, 2026
Merged

Perf: Optimize pages loading (Filecache path like approach)#2549
max-nextcloud merged 3 commits into
mainfrom
feature/optimize-pages-loading-v2

Conversation

@Koc

@KocKoc commented May 31, 2026

Copy link
Copy Markdown
Contributor

📝 Summary

This is alternative approach to #2390 that fixes same performance issue (closes#2380).

Benefits comparing to previous implementation:

  • no extra columns
  • no migration to re-process already existent page
  • no listeners
  • much simpler implementation

So, we're just load all necessary pages via simple query SELECT * FROM filecache WHERE storage_id = <storageId> AND path LIKE 'appdata_<instanceId>/collectives/<collectiveId>/%'

🖼️ Screenshots

image

Collective with 390 pages with various nesting level

🏚️ Before🏡 After
6.31s5.20s
imageimage
747 queries - depends on pages count and nesting level50 queries - more or less constant
imageimage

🚧 TODO

🏁 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits
  • Tests (unit, integration and/or end-to-end) passing and the changes are covered with tests
  • Documentation (README or documentation) has been updated or is not required

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI tools
  • The AI-generated content was reviewed, comprehended and tested by a human

@Koc
Kocforce-pushed the feature/optimize-pages-loading-v2 branch 4 times, most recently from 5d10baa to 5e6b2e9CompareMay 31, 2026 13:31
mejo-
mejo- previously requested changes Jun 9, 2026

@mejo-mejo- left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @Koc, this looks really promising 🤩

I have some comments, but I'm genuinely curious what you think about the comments.

If you do further changes to the PR, could you do them in separate fixup commits (and don't force-push changes to the existing commit for now) so it's easier to review your changes?

Comment threadlib/Service/PageService.php Outdated
Comment threadlib/Model/FileInfo.php Outdated
Comment threadlib/Mount/CollectiveFolderManager.php
Comment threadlib/Mount/CollectiveFolderManager.php
Comment threadlib/Service/PageService.php Outdated
Comment threadlib/Service/PageService.php Outdated
Comment threadlib/Mount/CollectiveFolderManager.php Outdated
Comment threadlib/Service/PageService.php Outdated
Comment threadlib/Model/PageInfo.php Outdated
Comment threadlib/Model/PageInfo.php
@KocKoc self-assigned this Jun 9, 2026
@Koc
Kocforce-pushed the feature/optimize-pages-loading-v2 branch 6 times, most recently from 3c03b17 to 980fb42CompareJune 14, 2026 22:19
@Koc

Koc commented Jun 14, 2026

Copy link
Copy Markdown
ContributorAuthor

We have green pipeline 🎉

@Koc
Kocforce-pushed the feature/optimize-pages-loading-v2 branch from 0ac5ab9 to 6937cb2CompareJune 15, 2026 09:37
@github-project-automationgithub-project-automationBot moved this to 🧭 Planning evaluation (don't pick) in 📝 Productivity teamJun 15, 2026
@max-nextcloudmax-nextcloud moved this from 🧭 Planning evaluation (don't pick) to 👀 In review in 📝 Productivity teamJun 15, 2026
@max-nextcloudmax-nextcloud self-assigned this Jun 15, 2026

@max-nextcloudmax-nextcloud left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proposing a refactoring of the getPagesFromFolder / buildPageInfoTree functions.

I'm pretty sure your approach works as well. I think this refactoring would still clarify things a lot. Would you be up for it or shall I give it a try and open a PR against this one?

Comment threadlib/Service/PageService.php Outdated
Comment threadlib/Service/PageService.php Outdated
@max-nextcloud

Copy link
Copy Markdown
Collaborator

Just tested this locally and performance wise it's really great. Managed to handle a collective with 2k pages well. Became somewhat slow from 3k on.
In comparison - on the same machine 700 pages were getting problematic before. So this seems to provide for approx 4-5 times as many pages.

@Koc

Koc commented Jun 18, 2026

Copy link
Copy Markdown
ContributorAuthor

@max-nextcloud@mejo- WDYT about adding a composite index to filecache table to columns storage_id, path? This can improve performance even more or large instances with millions files

@max-nextcloud

Copy link
Copy Markdown
Collaborator

@Koc there's the fs_storage_path_prefix cache (except for postgres dbs):
https://github.com/nextcloud/server/blob/master/core/Migrations/Version13000Date20170718121200.php#L244-L246

Might be interesting to confirm it's being used though. On my local instance requests for > 1k files were way below 1 second. That seems good enough.

@max-nextcloud

Copy link
Copy Markdown
Collaborator

From my point of view the next step would be to fetch the pages for even larger collectives in multiple requests.
I sketched my ideas about that here: #2581

@Koc

Koc commented Jun 21, 2026

Copy link
Copy Markdown
ContributorAuthor

@max-nextcloud heh we're using Postgres 😕 Why it's excluded?

I will try to work on your other comments next week

@max-nextcloud

Copy link
Copy Markdown
Collaborator

@max-nextcloud heh we're using Postgres 😕 Why it's excluded?

The latter seems to have some discussions on creating the index by hand to avoid the DBAL limitations.

@Koc
Kocforce-pushed the feature/optimize-pages-loading-v2 branch from 6937cb2 to 8806c19CompareJune 27, 2026 20:15
@Koc
Koc requested review from max-nextcloud and mejo-June 27, 2026 20:53
Koc added 3 commits June 29, 2026 23:12
Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
@Koc
Kocforce-pushed the feature/optimize-pages-loading-v2 branch from 795d7ac to 79f03d5CompareJune 29, 2026 21:16
@max-nextcloud

Copy link
Copy Markdown
Collaborator

Thanks a lot for your patience and commitment @Koc
I'll take another look to be sure and hope I can approve the PR then.

@max-nextcloudmax-nextcloud left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! 💙

@max-nextcloud

Copy link
Copy Markdown
Collaborator

Tracking behat failure in #2614

@max-nextcloud
max-nextcloud dismissed mejo-’s stale reviewJune 30, 2026 12:15

Issues have been adressed. Follow up issue created.

@max-nextcloud
max-nextcloud merged commit 6906d5f into mainJun 30, 2026
84 of 93 checks passed
@max-nextcloud
max-nextcloud deleted the feature/optimize-pages-loading-v2 branch June 30, 2026 14:10
@github-project-automationgithub-project-automationBot moved this from 👀 In review to ☑️ Done in 📝 Productivity teamJun 30, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Optimize performance of the pages loading by stopping using filesystem always

3 participants

@Koc@max-nextcloud@mejo-