Optimize console domain list fetch performance#3110
Closed
CydeWeys wants to merge 1 commit into
Closed
Conversation
d2895f9 to
3d72918
Compare
Optimize the domain list fetch action in the registrar console by implementing a lightweight DTO projection and a Two-Step Pagination Pattern. Previously, ConsoleDomainListAction returned a paginated list of full Domain JPA entities. During Gson serialization, accessing lazy-loaded element collections (specifically 'statuses' and 'nsHosts') triggered a massive N+1 query loop, executing hundreds of secondary SQL queries per request. In a previous optimization attempt, adding a collection fetch join to the paginated query triggered Hibernate's silent in-memory pagination trap, which fetched all registrar domains into the App Engine JVM memory, causing severe performance issues on alpha. This commit completely resolves the performance bottleneck by: 1. Introducing a lightweight 'ConsoleDomainInfo' DTO to expose only the five fields the frontend actually needs, avoiding loading unused heavy collections. 2. Implementing the Two-Step Pagination Pattern: - Step 1: Query the paginated page of domains (without collection fetch joins) to allow the database to execute a fast, native SQL LIMIT and OFFSET. - Step 2: Eagerly fetch the 'statuses' collection for only the returned page of domains (50 domains) using a single secondary query with an IN clause. 3. Mapping the results in memory to preserve the original sorted order and DTO structure, maintaining 100% backward compatibility with the Angular frontend. 4. Updating all stream assertions in 'ConsoleDomainListActionTest' to reference 'ConsoleDomainInfo' and verifying that the entire test suite passes successfully. TAG=agy CONV=610c2358-a99f-4605-94cd-ff0d4ee08176
3d72918 to
cfe9ed1
Compare
Member
Author
|
I'm not sure this is much of an improvement (if any), and it doesn't really seem to be helping things on alpha, so closing it for now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Optimize the domain list fetch action in the registrar console by implementing a lightweight DTO projection and eager fetch join to eliminate N+1 queries.
Previously, ConsoleDomainListAction returned a paginated list of full Domain JPA entities. During Gson serialization, accessing lazy-loaded element collections (specifically 'statuses' and 'nsHosts') triggered a massive N+1 query loop, executing hundreds of secondary SQL queries per request and causing the endpoint to take dozens of seconds (and sometimes fail with timeouts) on environments with large datasets like alpha.
This commit resolves the performance bottleneck by:
TAG=agy
CONV=610c2358-a99f-4605-94cd-ff0d4ee08176
This change is