Skip to content

Do not render the reference ID and key columns if RN does not equal.#2290

Open
chrshnv wants to merge 1 commit into
spring-projects:mainfrom
chrshnv:2122
Open

Do not render the reference ID and key columns if RN does not equal.#2290
chrshnv wants to merge 1 commit into
spring-projects:mainfrom
chrshnv:2122

Conversation

@chrshnv

@chrshnv chrshnv commented Apr 30, 2026

Copy link
Copy Markdown

This PR ensures that the ID and key columns of the reference table are not rendered when rn does not match with singlequeryloading enabled.

Closes #2122

Signed-off-by: Artemiy Chereshnevvv <chereshnevvv4real@gmail.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 30, 2026
@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 1, 2026
@lsh1215

lsh1215 commented Jun 24, 2026

Copy link
Copy Markdown

Hi, thanks for working on this.

I previously commented on #2122 that I wanted to work on the issue, but I wasn’t able to follow up at the time. I recently came back to it and noticed this PR.

While investigating the issue back then, I had also tried a similar change: rendering the reference id/key columns as null when the corresponding row number does not match rn. From what I saw, that addresses the correctness problem where a missing child row can still have non-null id/key columns and therefore be materialized incorrectly.

However, the part I got stuck on was the PostgreSQL performance concern described in #2122. The generated query shape still seems to build the child inline views without restricting them to the selected root ids, so on large tables PostgreSQL can still scan/window over many unrelated child rows before the outer join.

If that sounds reasonable, I’d like to work on the performance part as a follow-up PR, separately from this correctness fix. I’m happy to align with whatever direction the maintainers prefer.

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

Labels

type: bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spring data relational generates incorrect single query for PostgreSQL with two one-to-many relationships present

4 participants