Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 12839 invoked from network); 3 Nov 2007 17:26:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Nov 2007 17:26:13 -0000 Received: (qmail 95092 invoked by uid 500); 3 Nov 2007 17:26:00 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 95083 invoked by uid 500); 3 Nov 2007 17:26:00 -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 95074 invoked by uid 99); 3 Nov 2007 17:26:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Nov 2007 10:26:00 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of mkienenb@gmail.com designates 209.85.146.180 as permitted sender) Received: from [209.85.146.180] (HELO wa-out-1112.google.com) (209.85.146.180) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Nov 2007 17:26:04 +0000 Received: by wa-out-1112.google.com with SMTP id k22so1285997waf for ; Sat, 03 Nov 2007 10:25:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=KZ7MiQovj5WKdNBRJNPi+YkOuslCqm3Kpwgh4/HFSBs=; b=BZRJpGHmueQUoOGhAv1gRaSrClKgs++KGaOzL9F15raGoeJcxetJQSH9VfLm08U6GpOcsuEHeGw4b8AdoCV073ubcvNOmgDVC+v9OpK3L9GZMs6q8kBKZf1j4Y7LXj6zqU69iaCyN3HJbAOWgZjayvVfsTV+M6XDNtpI6KJbvkc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=WP1frPMjV3CFfTVrWVht1zgXfmWGyIJ7TqB27s0pd4ybEAwAegwbrDRUIoyZMGiFEze0tdpjxXCHur7BBDAv77UGbQ/wLYTrslHMDbboA509ESgjHkQff/UI6oDu0zyp6A0r2YGZxJXYzoTBA3+3NXXe6LMgwd65+ANkNvQcygw= Received: by 10.115.79.1 with SMTP id g1mr3220772wal.1194110742335; Sat, 03 Nov 2007 10:25:42 -0700 (PDT) Received: by 10.114.25.18 with HTTP; Sat, 3 Nov 2007 10:25:42 -0700 (PDT) Message-ID: <8f985b960711031025l7809bbebw8db7aee119cc1222@mail.gmail.com> Date: Sat, 3 Nov 2007 13:25:42 -0400 From: "Mike Kienenberger" To: user@cayenne.apache.org Subject: Re: localObject vs prefetches: would there be a benefit ? In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <2955A24F-43E6-46B2-AE39-A27F14754D8A@ish.com.au> <8f985b960711020623o2bf6330s430e835bb9fe0b43@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org Fetching one painting from the database is slower than copying one object. Fetching 300 paintings from the database is slower than copying 300 objects. Copy operations run at the speed of memory. Database operations run at the speed of networking and/or file I/O. On 11/2/07, Marcin Skladaniec wrote: > 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 > >> > > >