Cascade update generates n+1 queries #3042
Unanswered
Michael881188
asked this question in
General
Replies: 2 comments
-
It is not clear what is the shape of your entities. As I can see you have unidirectional entities? The likely cause of SELECT N+1 is updatable keys on relationships. Please refer to this SO answer: https://stackoverflow.com/a/7601312/259946 to fix the mapping. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I have bidirectional entities. I updated the mapping and added example classes. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
For example, I have:
And now, whenever I'm adding anything into Attributes array in User entity and saving it(collection of attributes is fully fetched before that). It generates n+1 queries. It is selecting 1 by 1 each Attribute and after that inserting all of them in 1 query. For ex. 10 attributes generate: 10 selects + 1 insert query.
I'm not sure, maybe something is wrong with my mapping but I didn't find any solution.
Beta Was this translation helpful? Give feedback.
All reactions