Unwanted query triggered when using a composite key on a self-referencing entity #11036
Unanswered
alexandrin-rus
asked this question in
Support Questions
Replies: 1 comment 2 replies
-
The foreign key column and the referenced column are the same column. That does not make sense at all. |
Beta Was this translation helpful? Give feedback.
2 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.
-
Hello,
I am encountering a strange issue and cannot understand why this is happening.
I have an entity that is using a composed primary key on the
instanceandridfields.I also have
parentas a self referencing relation to the same entity.The problem I am facing:
For the following data:
When retrieving a subscription using
findOneBy()I see 3 queries being triggered by Doctrine:This is the initial query, works as expected:
This is the query for the parent field, also working as expected:
This query is unexpected and cannot find a way to disable it or understand why it is triggered:
As you can see, the 3rd query tries to select all rows for that
instance_idwhich is a problem as our table is very large (millions of rows) and it would cause our database to crash. The retrieved object is built correctly and theparentproperty is populated as expected, but I would expect that query to not exist at all.Removing the
instanceas a composite key stops this behaviour, however we need it to work in this format, so it's not an option.Any idea what might be causing this additional query and how to get rid of it, so it will work as intended?
Beta Was this translation helpful? Give feedback.
All reactions