You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "bernard (JIRA)" <ji...@apache.org> on 2010/03/07 21:16:27 UTC
[jira] Created: (OPENJPA-1553) JPQL simple Child query generates
unnecessary Table Join
JPQL simple Child query generates unnecessary Table Join
--------------------------------------------------------
Key: OPENJPA-1553
URL: https://issues.apache.org/jira/browse/OPENJPA-1553
Project: OpenJPA
Issue Type: Bug
Components: jpa
Affects Versions: 2.0.0-beta2
Environment: Java 6
Reporter: bernard
The attached testcase demonstrates that for a basic child query, OpenJPA generates SQL that contains two joined tables where only one is required.
SELECT t0.id, t1.id FROM Child t0 LEFT OUTER JOIN Parent t1 ON t0.PARENT_ID = t1.id WHERE (t0.PARENT_ID = ?)
This creates performance issues. Please note that this is a simplified testcase - performance issues are of course not present in it.
It can be expected that JPA that provides a layer of abstraction by nature, generates optimized SQL.
In light of the fact that this is a 2.0 release, the priority of solving this should be high.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (OPENJPA-1553) JPQL simple Child query generates
unnecessary Table Join
Posted by "bernard (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OPENJPA-1553?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
bernard updated OPENJPA-1553:
-----------------------------
Attachment: SimpleJoin.zip
Testcase, NetBeans project in zip file
> JPQL simple Child query generates unnecessary Table Join
> --------------------------------------------------------
>
> Key: OPENJPA-1553
> URL: https://issues.apache.org/jira/browse/OPENJPA-1553
> Project: OpenJPA
> Issue Type: Bug
> Components: jpa
> Affects Versions: 2.0.0-beta2
> Environment: Java 6
> Reporter: bernard
> Attachments: SimpleJoin.zip
>
>
> The attached testcase demonstrates that for a basic child query, OpenJPA generates SQL that contains two joined tables where only one is required.
> SELECT t0.id, t1.id FROM Child t0 LEFT OUTER JOIN Parent t1 ON t0.PARENT_ID = t1.id WHERE (t0.PARENT_ID = ?)
> This creates performance issues. Please note that this is a simplified testcase - performance issues are of course not present in it.
> It can be expected that JPA that provides a layer of abstraction by nature, generates optimized SQL.
> In light of the fact that this is a 2.0 release, the priority of solving this should be high.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (OPENJPA-1553) JPQL simple Child query generates
unnecessary Table Join
Posted by "Fay Wang (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OPENJPA-1553?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12842742#action_12842742 ]
Fay Wang commented on OPENJPA-1553:
-----------------------------------
The left outer join is due to the default eager fetch of the ManyToOne relation in Child to Parent. If you annotate this relation to be lazily fetch, the left outer join will be gone.
@ManyToOne(fetch = FetchType.LAZY)
private Parent parent;
8863 join TRACE [main] openjpa.jdbc.SQL - <t 9470766, conn 26506390> executing prepstmnt 19823722 SELECT t0.id, t0.PARENT_ID FROM Child t0 WHERE (t0.PARENT_ID = ?) [params=(long) 1]
8903 join TRACE [main] openjpa.jdbc.SQL - <t 9470766, conn 26506390> [40 ms] spent
> JPQL simple Child query generates unnecessary Table Join
> --------------------------------------------------------
>
> Key: OPENJPA-1553
> URL: https://issues.apache.org/jira/browse/OPENJPA-1553
> Project: OpenJPA
> Issue Type: Bug
> Components: jpa
> Affects Versions: 2.0.0-beta2
> Environment: Java 6
> Reporter: bernard
> Attachments: SimpleJoin.zip
>
>
> The attached testcase demonstrates that for a basic child query, OpenJPA generates SQL that contains two joined tables where only one is required.
> SELECT t0.id, t1.id FROM Child t0 LEFT OUTER JOIN Parent t1 ON t0.PARENT_ID = t1.id WHERE (t0.PARENT_ID = ?)
> This creates performance issues. Please note that this is a simplified testcase - performance issues are of course not present in it.
> It can be expected that JPA that provides a layer of abstraction by nature, generates optimized SQL.
> In light of the fact that this is a 2.0 release, the priority of solving this should be high.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.