openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Struberg (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OPENJPA-2179) 'distinct' and 'join' combinations lead lots of unneccessary sub-queries for @Embedded and @Lob fields
Date Sat, 28 Apr 2012 10:19:48 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-2179?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13264285#comment-13264285
] 

Mark Struberg commented on OPENJPA-2179:
----------------------------------------

Btw, I preserved an old output of this phenomenon in a unit test of our app:

2012-04-26 17:13:36,657 [main]  DEBUG jdbc.SQL <t 169937755, conn 1482440345> executing
prepstmnt 1053577980 SELECT DISTINCT t1.id, t1.optlock, t1.blocked, t1.businessKey, t1.cancelled,
t1.comStuOk, t1.courseNr, t1.createdAt, t1.createdBy, t1.deanAcademicAffairsOk, t1.deleted,
t1.denied, t1.depStudOk, t1.ects, t1.elearningUrl, t1.firstAnnouncement, t1.formalError, t1.headOk,
t1.held, t1.hours, t1.language, t1.lecturerOk, t1.LINKEDCOURSE_ID, t1.modifiedAt, t1.modifiedBy,
t1.orgUntCode, t1.semesterCode, t1.titleDe, t1.titleEn, t1.tuwelUrl, t1.typeKey, t1.url, t1.veniaOk,
t1.visibilityDateElearningUrl, t1.visibilityDateTuwelUrl FROM Lecturer t0, Course t1 WHERE
t0.COURSE_ID = t1.id
2012-04-26 17:13:36,664 [main]  DEBUG jdbc.SQL <t 169937755, conn 1482440345> [7 ms]
spent
2012-04-26 17:13:36,665 [main]  DEBUG jdbc.SQLDiag load: class myapp.core.be.i18n.entities.LocalizedLongString
oid: 10060
2012-04-26 17:13:36,665 [main]  DEBUG jdbc.SQL <t 169937755, conn 1482440345> executing
prepstmnt 196270141 SELECT t0.examModalitiesDe, t0.examModalitiesEn FROM Course t0 WHERE t0.id
= ? [params=?]
2012-04-26 17:13:36,669 [main]  DEBUG jdbc.SQL <t 169937755, conn 1482440345> [4 ms]
spent
2012-04-26 17:13:36,673 [main]  DEBUG jdbc.SQLDiag load: class myapp.core.be.i18n.entities.LocalizedLongString
oid: 10060
2012-04-26 17:13:36,673 [main]  DEBUG jdbc.SQL <t 169937755, conn 1482440345> executing
prepstmnt 802857302 SELECT t0.lectureNotesInfoDe, t0.lectureNotesInfoEn FROM Course t0 WHERE
t0.id = ? [params=?]
2012-04-26 17:13:36,677 [main]  DEBUG jdbc.SQL <t 169937755, conn 1482440345> [4 ms]
spent
2012-04-26 17:13:36,682 [main]  DEBUG jdbc.SQLDiag load: class myapp.core.be.i18n.entities.LocalizedLongString
oid: 10060
2012-04-26 17:13:36,682 [main]  DEBUG jdbc.SQL <t 169937755, conn 1482440345> executing
prepstmnt 1253026437 SELECT t0.objectiveDe, t0.objectiveEn FROM Course t0 WHERE t0.id = ?
[params=?]
2012-04-26 17:13:36,686 [main]  DEBUG jdbc.SQL <t 169937755, conn 1482440345> [4 ms]
spent
2012-04-26 17:13:36,698 [main]  DEBUG jdbc.SQLDiag load: class myapp.core.be.i18n.entities.LocalizedLongString
oid: 10060
2012-04-26 17:13:36,698 [main]  DEBUG jdbc.SQL <t 169937755, conn 1482440345> executing
prepstmnt 199943961 SELECT t0.recommendationDe, t0.recommendationEn FROM Course t0 WHERE t0.id
= ? [params=?]
2012-04-26 17:13:36,702 [main]  DEBUG jdbc.SQL <t 169937755, conn 1482440345> [4 ms]
spent
2012-04-26 17:13:36,728 [main]  DEBUG jdbc.SQLDiag load: class myapp.core.be.i18n.entities.LocalizedLongString
oid: 10060
2012-04-26 17:13:36,728 [main]  DEBUG jdbc.SQL <t 169937755, conn 1482440345> executing
prepstmnt 25287543 SELECT t0.remarkDe, t0.remarkEn FROM Course t0 WHERE t0.id = ? [params=?]
2012-04-26 17:13:36,732 [main]  DEBUG jdbc.SQL <t 169937755, conn 1482440345> [4 ms]
spent
2012-04-26 17:13:36,738 [main]  DEBUG jdbc.SQLDiag load: class myapp.core.be.i18n.entities.LocalizedLongString
oid: 10060
2012-04-26 17:13:36,738 [main]  DEBUG jdbc.SQL <t 169937755, conn 1482440345> executing
prepstmnt 1802848163 SELECT t0.contentDe, t0.contentEn FROM Course t0 WHERE t0.id = ? [params=?]
2012-04-26 17:13:36,742 [main]  DEBUG jdbc.SQL <t 169937755, conn 1482440345> [4 ms]
spent
2012-04-26 17:13:36,750 [main]  DEBUG jdbc.SQLDiag load: class myapp.course.be.entities.Course
oid: 10060

all the LocalizedLongString are @Embedded fields directly in the Course entity. This effect
doesn't happen with the MySqlDictionary.
                
> 'distinct' and 'join' combinations lead lots of unneccessary sub-queries for @Embedded
and @Lob fields
> ------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-2179
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2179
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 2.2.0
>            Reporter: Mark Struberg
>            Assignee: Mark Struberg
>             Fix For: 2.3.0
>
>
> I have an Entity (Course) with a simple @Embedded field and a @Lob. I do not use any
LAZY attribution on them!
> If I do a normal em.find, the entity will be loaded as a whole (all the fields, including
the embedded and the lob will be fetched immediately).
> Sidenote: the Lecturer referred in the select is defined as
>     @OneToMany(mappedBy = "course",
>             cascade = {CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.MERGE},
>             orphanRemoval = true, fetch = FetchType.EAGER)
>     @OrderColumn(name = "POSITION")
>     private List<Lecturer> lecturers;
> The following selects DO work
> * "select c from Course c join c.lecturers l "
> * "select distinct c from Course c"
> The following selects create tons of subqueries! 1 separate sub-query for each @Embedded
field, and also for each @Lob
> * "select distinct c from Course c join c.lecturers l "
> * "select distinct c from Lecturer l join l.course c"
> * "select c from Lecturer l join l.course c" 
> This happens ONLY if I run this stuff against Oracle. In MySQL it seems to work properly.
> I'll try to create a unit test for it.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message