Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load arbitrary aggregates with a single select #1445

Open
4 of 12 tasks
schauder opened this issue Mar 10, 2023 · 3 comments
Open
4 of 12 tasks

Load arbitrary aggregates with a single select #1445

schauder opened this issue Mar 10, 2023 · 3 comments
Labels
in: single-query-loading Everything related to querying aggregates with a single select. type: enhancement A general enhancement

Comments

@schauder
Copy link
Contributor

schauder commented Mar 10, 2023

This should resolve #592. I opted for a separate issue in order to allow for a more focused discourse about this specific approach.

We have a concept for how to load arbitrary aggregates with a single select statement, at least for those databases that support a sufficient subset of the SQL standard.

This ticket is an epic for tracking the progress in the implementation this concept.

Subtickets:

@schauder schauder added in: single-query-loading Everything related to querying aggregates with a single select. type: enhancement A general enhancement labels Mar 10, 2023
@mp911de mp911de changed the title Load arbitrary aggregates with a single select. Load arbitrary aggregates with a single select Mar 10, 2023
@devfarzane
Copy link

Hi, thanks for this enhancement.
I just wanted to know is there any plans for this feature? Like when implementation process is going to start and in which spring version we can use it?
I'm specifically interested in single queries using R2DBC.

@schauder
Copy link
Contributor Author

The implementation started and we hope to make first parts available during 2023.

schauder added a commit that referenced this issue Jul 21, 2023
Single Query Loading loads as the name suggests complete aggregates using a single select.
While the ultimate goal is to support this for all aggregates, this commit enables it only for simple aggregate and also only for some operations.
A simple aggregate is an aggregate that only reference up to one other entity and does not have embedded entities.
The supported operations are those available via `CrudRepository`: `findAll`, `findById`, and `findAllByIds`.

Single Query Loading does NOT work with the supported in memory databases H2 and HSQLDB, since these do not properly support windowing functions, which are essential for Single Query Loading.

To turn off Single Query Loading call `RelationalMappingContext.setSingleQueryLoadingEnabled(false)`.

Closes #1446
See #1450
See #1445
schauder added a commit that referenced this issue Jul 21, 2023
Single Query Loading loads as the name suggests complete aggregates using a single select.
While the ultimate goal is to support this for all aggregates, this commit enables it only for simple aggregate and also only for some operations.
A simple aggregate is an aggregate that only reference up to one other entity and does not have embedded entities.
The supported operations are those available via `CrudRepository`: `findAll`, `findById`, and `findAllByIds`.

Single Query Loading does NOT work with the supported in memory databases H2 and HSQLDB, since these do not properly support windowing functions, which are essential for Single Query Loading.

To turn off Single Query Loading call `RelationalMappingContext.setSingleQueryLoadingEnabled(false)`.

Closes #1446
See #1450
See #1445
schauder added a commit that referenced this issue Jul 21, 2023
Single Query Loading loads as the name suggests complete aggregates using a single select.
While the ultimate goal is to support this for all aggregates, this commit enables it only for simple aggregate and also only for some operations.
A simple aggregate is an aggregate that only reference up to one other entity and does not have embedded entities.
The supported operations are those available via `CrudRepository`: `findAll`, `findById`, and `findAllByIds`.

Single Query Loading does NOT work with the supported in memory databases H2 and HSQLDB, since these do not properly support windowing functions, which are essential for Single Query Loading.

To turn on Single Query Loading call `RelationalMappingContext.setSingleQueryLoadingEnabled(true)`.

Closes #1446
See #1450
See #1445
mp911de pushed a commit that referenced this issue Aug 15, 2023
Single Query Loading loads as the name suggests complete aggregates using a single select.
While the ultimate goal is to support this for all aggregates, this commit enables it only for simple aggregate and also only for some operations.
A simple aggregate is an aggregate that only reference up to one other entity and does not have embedded entities.
The supported operations are those available via `CrudRepository`: `findAll`, `findById`, and `findAllByIds`.

Single Query Loading does NOT work with the supported in memory databases H2 and HSQLDB, since these do not properly support windowing functions, which are essential for Single Query Loading.

To turn on Single Query Loading call `RelationalMappingContext.setSingleQueryLoadingEnabled(true)`.

Closes #1446
See #1450
See #1445
Original pull request: #1572
mp911de added a commit that referenced this issue Aug 15, 2023
Extract Single Query Loading branching to SingleQueryFallbackDataAccessStrategy. Inline AggregateReaderFactory into SingleQueryDataAccessStrategy. Move CachingSqlGenerator to AggregateReader as caching root.

Introduce DataAccessStrategyFactory to encapsulate configuration.

Fix Javadoc tag ordering. Remove superfluous MappingContext parameters when Converter is available. Simplify code. Reformat code.

Reorder Functions methods. Tweak Javadoc, move composite function into SingleQuerySqlGenerator.

See #1446
See #1450
See #1445
Original pull request: #1572
mp911de added a commit that referenced this issue Aug 15, 2023
Transform the tabular structure into a graph of RowDocument associated with nested documents and lists.

Add container license acceptance for updated container images.

See #1446
See #1450
See #1445
Original pull request: #1572
@mhyeon-lee
Copy link
Contributor

mhyeon-lee commented Aug 31, 2023

I'm very excited to see that Spring Data JDBC is addressing this issue
I solved the problem in the same way as presented in this blog post and published the code. (Single Query and Aggregate ResultSet Mapping)
This is the Beginning of the End of the N+1 Problem: Introducing Single Query Loading.

Spring JDBC Plus is a library that extends Spring JDBC and Spring Data JDBC.

This feature is very useful.
I'm looking forward to seeing it nicely addressed in Spring Data JDBC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: single-query-loading Everything related to querying aggregates with a single select. type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants