Skip to content

Cache and bound the collection page link check #12672 - #12675

Open
ErykKul wants to merge 1 commit into
developfrom
12672-collection-page-linking-popup-performance
Open

Cache and bound the collection page link check #12672#12675
ErykKul wants to merge 1 commit into
developfrom
12672-collection-page-linking-popup-performance

Conversation

@ErykKul

@ErykKul ErykKul commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it:

Makes the collection page's Link button check cheap again. DataversePage.showLinkingPopup() is bound to rendered= in two places in dataverse.xhtml, so it is evaluated repeatedly per request, and it computed its answer from the full list of collections the user may link — for a superuser, SELECT id, name, alias FROM DATAVERSE with an entity per row. That is a sequential scan of the dataverse table several times per collection page load, for logged-in users only, which is what made qa.dataverse.org unusable (#12672).

Two changes, no behavior change:

  • showLinkingPopup() memoizes into a Boolean field, cleared by setDataverse. Same pattern DatasetPage already uses for its own showLinkingPopup field and for hasDataversesToChoose.
  • New PermissionServiceBean.findSomePermittedCollections(..., limit) appends LIMIT n to the same base SQL, as the existing hasMultiplePermittedCollections does with LIMIT 2. The existence check asks for 1 row; the eligibility check asks for 2 + ancestorCount. The current collection and its parent tree are the only collections removeUnlinkableDataverses can drop here, so one candidate beyond that tree decides the question: fewer rows than the limit means we have the complete set and filter exactly; a full limit means at least one row falls outside the exclusion set.

Which issue(s) this PR closes:

Special notes for your reviewer:

This is the alternative to reverting #12250 (#12674). If the revert lands first, this needs rebasing onto the re-land rather than onto develop.

Deliberately unchanged: the query != null branch is dead code (DataversePage.query is never assigned — the collection page's search query lives on SearchIncludeFragment.query), but rewiring it would change who sees the Link button, so it is left alone. Worth a follow-up issue.

Also left alone: updateLinkableDataverses() still fetches the full list, but it only runs when someone opens the Link dialog and it needs every row for the dropdown. It was unbounded before #12250 too (findAll()), so it is not part of this regression.

Two things this does not fix, both worth their own issues: the superuser branch of findPermittedCollections is still an unbounded scan for its four remaining callers (all API/action paths, none per-render), and it selects three columns while mapping to Dataverse.class, which someone should check in a SQL log for per-row fetches.

Suggestions on how to test this:

Log in as a superuser and load a collection page, including the root collection. It should be as fast as it is when logged out. The Link button should still appear when you have LinkDataverse on some other collection and not when you do not, and the Link dialog should still list the same collections. pg_stat_statements should no longer show FROM DATAVERSE dv accumulating calls per page render.

Does this PR introduce a user interface change? If mockups are available, please link/include them here:

No.

Is there a release notes update needed for this change?:

No — #12250 is unreleased, so this is a fix within the same cycle.

Additional documentation:

None.

@github-actions github-actions Bot added the FY27 Sprint 5 FY27 Sprint 5 (2026-08-26 - 2026-09-09) label Sep 9, 2026
@ErykKul
ErykKul requested a review from vera September 9, 2026 14:49
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage is 25.411%12672-collection-page-linking-popup-performance into develop. No base build found for develop.

@ErykKul

ErykKul commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

@vera
Possible fix that AI suggested; not sure if it fixes the problem and is the right way to do it. If not helpful, we can just close this PR.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

Test Results

405 tests   390 ✅  33m 41s ⏱️
 55 suites   15 💤
 55 files      0 ❌

Results for commit f54777b.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FY27 Sprint 5 FY27 Sprint 5 (2026-08-26 - 2026-09-09) Status: Merge Conflicts Merge conflicts must be resolved.

Projects

Status: Ready for Triage

Development

Successfully merging this pull request may close these issues.

6.12 release candidate (d59202b) is super slow

4 participants