DDC-1552: JTI Owning table for identifier columns could/should be the entitytable #1950

Open
opened 2026-01-22 13:33:02 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Dec 22, 2011).

Originally assigned to: @asm89 on GitHub.

Jira issue originally created by user @asm89:

When ordering a JTI entity on id, the generated SQL will use the table of the root entity. This is because the root entity is listed as owner of the field in the _owningTableMap, leading to non-optimal queries.

More information see:
https://groups.google.com/forum/#!topic/doctrine-user/znkkP7IF_Aw

Originally created by @doctrinebot on GitHub (Dec 22, 2011). Originally assigned to: @asm89 on GitHub. Jira issue originally created by user @asm89: When ordering a JTI entity on id, the generated SQL will use the table of the root entity. This is because the root entity is listed as owner of the field in the _owningTableMap, leading to non-optimal queries. More information see: https://groups.google.com/forum/#!topic/doctrine-user/znkkP7IF_Aw
admin added the Improvement label 2026-01-22 13:33:02 +01:00
Author
Owner

@doctrinebot commented on GitHub (Dec 22, 2011):

Comment created by @asm89:

I can pick this up if it's agreed upon that this could indeed be improved.

@doctrinebot commented on GitHub (Dec 22, 2011): Comment created by @asm89: I can pick this up if it's agreed upon that this could indeed be improved.
Author
Owner

@doctrinebot commented on GitHub (Dec 22, 2011):

Comment created by @ocramius:

The problem here is that joining with a JTI causes LEFT JOINS, which don't perform very well when it comes to sorting the results.

Just as a quick reference, here's where "something" should be changed to get this working:
https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Query/SqlWalker.php#L316

When the field is part of the primary key, the field used for sorting results should be the one of the table of the entity itself, and not of the root of the CTI.

@doctrinebot commented on GitHub (Dec 22, 2011): Comment created by @ocramius: The problem here is that joining with a JTI causes LEFT JOINS, which don't perform very well when it comes to sorting the results. Just as a quick reference, here's where "something" should be changed to get this working: https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Query/SqlWalker.php#L316 When the field is part of the primary key, the field used for sorting results should be the one of the table of the entity itself, and not of the root of the CTI.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1950