Return-Path: X-Original-To: apmail-cxf-issues-archive@www.apache.org Delivered-To: apmail-cxf-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A45D111DC9 for ; Tue, 6 May 2014 21:30:28 +0000 (UTC) Received: (qmail 11891 invoked by uid 500); 6 May 2014 20:17:09 -0000 Delivered-To: apmail-cxf-issues-archive@cxf.apache.org Received: (qmail 10566 invoked by uid 500); 6 May 2014 20:14:34 -0000 Mailing-List: contact issues-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list issues@cxf.apache.org Received: (qmail 6695 invoked by uid 99); 6 May 2014 20:04:29 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 May 2014 20:04:29 +0000 Date: Tue, 6 May 2014 20:04:29 +0000 (UTC) From: "Romain Castan (JIRA)" To: issues@cxf.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (CXF-5731) FIQL: Optimizing queries with JPA MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CXF-5731?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Romain Castan updated CXF-5731: ------------------------------- Labels: patch (was: ) > 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: 3.0.0-milestone1, 3.0.0-milestone2, 2.7.11 > Reporter: Romain Castan > Labels: patch > Attachments: patch.txt > > > 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 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)