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

Optimize Queries #21967

Closed
shresthaujjwal opened this issue Apr 29, 2023 · 3 comments · Fixed by #25073
Closed

Optimize Queries #21967

shresthaujjwal opened this issue Apr 29, 2023 · 3 comments · Fixed by #25073

Comments

@shresthaujjwal
Copy link

Overview of the issue

Need ways to optimize query so that there is a single inner join query for all 1-many join tables, currently by design if you have too many 1-many tables and if you use default jhipster built-in specification criteria it does lot of select to get the end result instead of doing just single 1 inner join to all the tables to get the result back.

Motivation for or Use Case

If you have to many select query instead of just 1 select query with inner join you will save the network cost when you are working with application with cross region traffic where database is cross region and is traffic has 50ms latency and it adds up, lets say you have 200 record and have 5 table that you have 1-many relation and you need to inner join, now by default using jpa/hibernate it will do 1000 select queries to get the end result will be a very costly transactions

@amatosg
Copy link
Contributor

amatosg commented May 5, 2023

this happened to me. It takes about 3 seconds to get 20 entities. I had to use statements & executeQuery

@deepu105
Copy link
Member

how would you suggest optimizing it in the generated code given there could be any number of relationship combinations

@amatosg
Copy link
Contributor

amatosg commented Aug 22, 2023

I've tried using nativeQuery and even that doesn't help, the query has multiple joins making the retrieval of only 20 records take about 3 seconds. Using executeQuery takes about 50ms

@deepu105 deepu105 added this to the 8.2.0 milestone Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants