Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 41699 invoked from network); 2 Nov 2007 21:13:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Nov 2007 21:13:50 -0000 Received: (qmail 75993 invoked by uid 500); 2 Nov 2007 21:13:37 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 75970 invoked by uid 500); 2 Nov 2007 21:13:37 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 75957 invoked by uid 99); 2 Nov 2007 21:13:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Nov 2007 14:13:37 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of marcin@ish.com.au designates 59.167.240.32 as permitted sender) Received: from [59.167.240.32] (HELO fish.ish.com.au) (59.167.240.32) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Nov 2007 21:14:00 +0000 Received: from [10.29.64.41] (helo=[10.29.64.41]) by fish.ish.com.au with esmtp (Exim 4.43) id 1Io3s0-0002jq-8I for user@cayenne.apache.org; Sat, 03 Nov 2007 08:16:01 +1100 Message-Id: From: Marcin Skladaniec To: user@cayenne.apache.org In-Reply-To: <8f985b960711020623o2bf6330s430e835bb9fe0b43@mail.gmail.com> Content-Type: multipart/signed; boundary=Apple-Mail-55-982423908; micalg=sha1; protocol="application/pkcs7-signature" Mime-Version: 1.0 (Apple Message framework v912) Subject: Re: localObject vs prefetches: would there be a benefit ? Date: Sat, 3 Nov 2007 07:13:08 +1000 References: <2955A24F-43E6-46B2-AE39-A27F14754D8A@ish.com.au> <8f985b960711020623o2bf6330s430e835bb9fe0b43@mail.gmail.com> X-Mailer: Apple Mail (2.912) X-Spam-Score: -1.4 (-) X-Spam-Report: -1.4 ALL_TRUSTED Passed through trusted hosts only via SMTP X-Virus-Checked: Checked by ClamAV on apache.org --Apple-Mail-55-982423908 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Hi Mike Thats exactly what I mean: localObject is copying one object at the time. So say I have in my contextA 1 Gallery with 300 related Paintings, all with PersistentState.COMMITED. I do contextB.localObject on Gallery, then I access every Painting via relaionship. this means that the localObject will be invoked 301 times, everytime with single object. I believe this will be faster than re-fetching the data, but what if there will be 3000 Paintings ? Is there a limit after which the localObject becomes slower than re- fetch ? Marcin On 02/11/2007, at 11:23 PM, Mike Kienenberger wrote: > I am no expert in this subject, but the cost of doing I/O is always > going to exceed the cost of in-system memory copies, probably by > orders of magnitude. The only place where this might not be true is > using an in-memory database such as an HSQLDB mem jdbc connection. > > So unless you're copying orders-of-magnitude more data than you'd be > fetching, always copy. > > Remember too that a localObject only copies the object, not any of its > relationships. And the other objects are only pulled in if you > access them, which is even more fine-grained than prefetching. > > So my guess is that localObject is ALWAYS orders of magnitude faster. > I suspect it'd be extremely difficult to define a situation where this > was not the case. > > On 11/1/07, Marcin Skladaniec wrote: >> Hi >> >> We are improving the performance of our client application (ROP). Not >> surprisingly we have found that adding prefetches did improve the >> speed significantly. >> >> I have a question though about which is about efficiency of >> localObject. We are fetching a list of objects (query with >> prefetches) >> to a specific one non-editable context. If the object is to be edited >> it has to be copied to another context which allows committing >> changes. After the object is copied all the related object are >> accessed, so the performance of the copying came to my mind. >> >> The test I have looks like this: >> >> CayenneContext context1; >> CayenneContext context2; >> >> SelectQuery q = new SelectQuery(Painting.class); >> q.addPrefetch(Painting.GALLERY_PROPERTY); >> q.addPrefetch(Painting. GALLERY_PROPERTY + "." + >> Gallery.CITY_PROPERTY); >> List l = context1.performQuery(q); >> //now the context1 contain all the records I wanted it to contain >> >> Painting p1 = (Painting) l.get(0); >> Painting p2 = (Painting) context2.localObject(p1.getObjectId(), >> null); >> >> //now the context2 contain only the single record I copied >> p2.getGallery().getCity(); >> //now context2 contains the same objects as context1 >> >> All is very quick, but my question is how it will scale when the >> relationship would be to-many and there will be hundreds related >> records. >> >> What do you think would be a threshold number of related objects >> which >> have to be localised over which it would be worth doing a new, >> specific select query for that single object (with prefetches). Would >> there be advantage of doing that at all ? >> >> We are using cutting edge version of cayenne (I think we use build >> about 2-3 weeks old). >> >> Marcin >> --Apple-Mail-55-982423908 Content-Disposition: attachment; filename=smime.p7s Content-Type: application/pkcs7-signature; name=smime.p7s Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGIzCCAtww ggJFoAMCAQICEH04uRLie7YYyXPPwOrwracwDQYJKoZIhvcNAQEFBQAwYjELMAkGA1UEBhMCWkEx JTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMTI1RoYXd0ZSBQ ZXJzb25hbCBGcmVlbWFpbCBJc3N1aW5nIENBMB4XDTA3MTAyMDAxNDg0OVoXDTA4MTAxOTAxNDg0 OVowQzEfMB0GA1UEAxMWVGhhd3RlIEZyZWVtYWlsIE1lbWJlcjEgMB4GCSqGSIb3DQEJARYRbWFy Y2luQGlzaC5jb20uYXUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDu7dUT0rWcPhY8 Taf7mqzfUJTad8M5+Z535eVrhnvrPRTQxP/+4xqxykUsSiID4WbD9jZrN9qXt52wbbROlUzu4Psj E0HXbSgnigGwn8ktbCg3LEH36p2YvkFwwrk9qPE8VNR6hZ+6BtBvJ1lpSkNZCYjOMnXoKwt2gFJv Iespvi9TgPTNLHJ6mHqIXDBymAJMwQY69Yi91B0pcZpTCeJV3xNoOjkf/FwBWrJJmGOVuwnYgMrJ k26wM5rRfRgUB2lRv0gTvIhW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