cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Romain Castan (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CXF-5731) FIQL: Optimizing queries with JPA
Date Tue, 06 May 2014 14:01:38 GMT
Romain Castan created CXF-5731:
----------------------------------

             Summary: FIQL: Optimizing queries with JPA
                 Key: CXF-5731
                 URL: https://issues.apache.org/jira/browse/CXF-5731
             Project: CXF
          Issue Type: Improvement
          Components: JAX-RS
    Affects Versions: 2.7.11, 3.0.0-milestone2, 3.0.0-milestone1
            Reporter: Romain Castan


I analysed the query generated because I had some performance problems.
I saw that the joins are created for each FIQL expression.
If two FIQL expressions require the same join it's not necessary to create two joins.
I enabled the log to display the query with hibernate:
add this line <property name="hibernate.show_sql" value="true"/> in persistance.xml
I launched the following unit test: JPATypedQueryVisitorTest.testAndQueryCollection
The query result is:
select 
book0_.id as id0_, 
book0_.houseNumber as houseNum2_0_, 
book0_.street as street0_, 
book0_.bookTitle as bookTitle0_, 
book0_.library_id as library7_0_, 
book0_.dateOfBirth as dateOfBi5_0_, 
book0_.thename as thename0_ 
from Book book0_ 
inner join Book_authors authors1_ on book0_.id=authors1_.Book_id 
inner join Book_BookReview reviews2_ on book0_.id=reviews2_.Book_id 
inner join BookReview bookreview3_ on reviews2_.reviews_id=bookreview3_.id 
inner join Book_BookReview reviews4_ on book0_.id=reviews4_.Book_id 
inner join BookReview bookreview5_ on reviews4_.reviews_id=bookreview5_.id 
inner join BookReview_authors authors6_ on bookreview5_.id=authors6_.BookReview_id 
where 
cast(book0_.id as integer)=10 
and authors1_.authors=? 
and bookreview3_.review=? 
and authors6_.authors=?

There are two "inner join" which are not necessary because they are duplicated. 
The query could be:
select 
book0_.id as id0_, 
book0_.houseNumber as houseNum2_0_, 
book0_.street as street0_, 
book0_.bookTitle as bookTitle0_, 
book0_.library_id as library7_0_, 
book0_.dateOfBirth as dateOfBi5_0_, 
book0_.thename as thename0_ 
from Book book0_ 
inner join Book_authors authors1_ on book0_.id=authors1_.Book_id 
inner join Book_BookReview reviews2_ on book0_.id=reviews2_.Book_id 
inner join BookReview bookreview3_ on reviews2_.reviews_id=bookreview3_.id 
inner join BookReview_authors authors4_ on bookreview3_.id=authors4_.BookReview_id 
where 
cast(book0_.id as integer)=10 
and authors1_.authors=? 
and bookreview3_.review=? 
and authors4_.authors=? 



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message