Return-Path: X-Original-To: apmail-cayenne-dev-archive@www.apache.org Delivered-To: apmail-cayenne-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5EBD010BD1 for ; Wed, 18 Dec 2013 04:26:46 +0000 (UTC) Received: (qmail 27979 invoked by uid 500); 18 Dec 2013 04:26:46 -0000 Delivered-To: apmail-cayenne-dev-archive@cayenne.apache.org Received: (qmail 27877 invoked by uid 500); 18 Dec 2013 04:26:46 -0000 Mailing-List: contact dev-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list dev@cayenne.apache.org Received: (qmail 27869 invoked by uid 99); 18 Dec 2013 04:26:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Dec 2013 04:26:46 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy includes SPF record at spf.trusted-forwarder.org) Received: from [59.167.249.15] (HELO fish.ish.com.au) (59.167.249.15) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Dec 2013 04:26:39 +0000 Received: from ip-136.ish.com.au ([203.29.62.136]:54970) by fish.ish.com.au with esmtpsa (UNKNOWN:CAMELLIA256-SHA:256) (Exim 4.76) (envelope-from ) id 1Vt8i4-00067J-1Q for dev@cayenne.apache.org; Wed, 18 Dec 2013 15:26:12 +1100 X-CTCH-RefID: str=0001.0A150201.52B123E4.01AA,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0 Message-ID: <52B123E3.2020006@maniatis.org> Date: Wed, 18 Dec 2013 15:26:11 +1100 From: Aristedes Maniatis User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:26.0) Gecko/20100101 Thunderbird/26.0 MIME-Version: 1.0 To: dev@cayenne.apache.org Subject: Re: cayenne performance tuning issues References: <52B11B5E.7070403@maniatis.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Prefetching is not supposed to change the records that you return from the query in the primary table. Which is why a left join is appropriate. An inner join would suppress records in the primary table without a relation to the second table. That might be what you want, but that isn't the point of prefetching which is purely to improve performance of otherwise working code. At any rate, your 30 second SQL query isn't anything to do with prefetching. As Mike pointed out, you need to understand why this query is taking so long and you might like to execute it directly in your database or execute it with the word "EXPLAIN" before the select query. Ari On 18/12/2013 3:09pm, Michael Hatch wrote: > I did testing with default prefetching disjoint joint semantics and joint > prefetching. As you stated, disjoint sends multiple SQL requests. I'm not > sure which scenario that would be preferred. Joint semantics seems to > create left joins, although I'd want inner joins. Is there an option to > prefetch and inner join? Didn't look to be the case > On Dec 17, 2013 9:50 PM, "Aristedes Maniatis" wrote: > >> On 18/12/2013 4:29am, Michael Hatch wrote: >> >>> The first sql statement is fetching the user info, while the second sql >> is >>> for inflating the roles relationship. I understand the documentation >>> explicitly states that prefetching will inflate relationships for you, >> but >>> it still does so via multiple sql commands per relationship, instead of >> via >>> a single sql statement with an inner join. Did I simply do something >> wrong >>> somewhere? >> >> Cayenne will automatically decide whether to issue multiple SQL requests >> (disjoint prefetch) or one big SQL statement which captures all the data >> (joint). Don't assume without testing which one will be better for your >> needs, and Cayenne does allow you to choose which sementics to use. But >> SelectQuery will be disjoint by default. >> >> Imagine for a moment: to-many joins to 5 tables from a source table on >> which you want to use a joint prefetch. You can very quickly return a vast >> number of rows using an outer join in this way. >> >> Ari >> >> >> -- >> --------------------------> >> Aristedes Maniatis >> GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A >> > -- --------------------------> Aristedes Maniatis GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A