It sounds like you have a large to-many relationship. Best advice: Remove it.
In your model, you have A<->>B? Did you know whenever you create a new B, you fetch all B related to A as a result? It goes like this. New B, setARelationship() on B, that calls addObjectToBothSides, which fetches all of A’s b() to insert the single new B into it. If you have thousands of related Bs, then that’s not going to be efficient. Compounding that, it sounds like somewhere in this process your app is flagging all the Bs as updated and as a result of optimistic locking, doing a select on every single one of them to ensure they haven’t changed before realizing the update is a no-op. So just remove the relationship and replace it with a cover method that fetches related B if required. If you really really need the relationship for EOQualifiers, then keep the relationship, but remove it as a class property. Or not. That’s what I would try first :) On Feb 14, 2015, at 6:24 AM, OC <[email protected]> wrote: > Hello there, > > as Alice said, it gets couriouser and couriouser. I am now logging SQL, and > -- at least to me -- it seems my application is SELECTing way too often. > > The code is still related to the price offers of my previous posts; this time > though I am using the default EC and I am not setting fetchTimestamp. > > I am creating new objects in an entity DBPriceOffer and adding them to 1:N > relationship of an entity DBUser -- all of them to the same user. > > Now, what I would (naïvely?) assume is that > (a) the first time this happens, the user's price offers _might be_ fetched > (not necessarily, but possibly) > (b) nevertheless, when they _are_ once fetched into the EC, they won't be > re-fetched anytime soon, for EC caches them and EOF does not make unnecessary > roundtrips to the DB. > > They get re-fetched though -- each sweet time again, with the same EC, no > fetchTimestamp. My app never refaults nor refreshes anything. There's about > 95 % free heap, so there should be no flushing of soft caches, if WO uses > them at all. My current code looks like this: > > === > DBPriceOffer o=new DBPriceOffer() > createdBy.editingContext.insertObject(o) > ... > println "WEIRD 27 newo: $o, creator: $createdBy // EC:${o.editingContext()} > (FTS:${(System.currentTimeMillis()-o.editingContext().fetchTimestamp())/1000} > s)" > o.addObjectToBothSidesOfRelationshipWithKey(createdBy,'user') > //createdBy.addObjectToBothSidesOfRelationshipWithKey(o,'priceOffers') // > tried this too, works precisely same way > println "WEIRD 31 > === > > and adding price offers through this code _always_ re-fetches the user's > relationship into which they are being added: > > === > WEIRD 27 newo: <DBPriceOffer@1247321477 PK:null N /EC:176991315>, creator: > <DBUser@2069151341 PK:1000008 Name:'cl' /EC:176991315> // > EC:er.extensions.eof.ERXEC@a8cac53 (FTS:3996.348 s) > 14:09:16.912 DEBUG evaluateExpression: > <com.webobjects.jdbcadaptor.FrontbasePlugIn$FrontbaseExpression: "SELECT ... > FROM "T_PRICE_OFFER" t0 WHERE t0."C_CREATOR_ID" = 1000008" withBindings: > > 14:09:16.922 DEBUG 179 row(s) processed > WEIRD 31 > ... > WEIRD 27 newo: <DBPriceOffer@81493054 PK:null N /EC:176991315>, creator: > <DBUser@2069151341 PK:1000008 Name:'cl' /EC:176991315> // > EC:er.extensions.eof.ERXEC@a8cac53 (FTS:4001.53 s) > 14:09:22.090 DEBUG evaluateExpression: > <com.webobjects.jdbcadaptor.FrontbasePlugIn$FrontbaseExpression: "SELECT ... > FROM "T_PRICE_OFFER" t0 WHERE t0."C_CREATOR_ID" = 1000008" withBindings: > > 14:09:22.099 DEBUG 180 row(s) processed > WEIRD 31 > ... > WEIRD 27 newo: <DBPriceOffer@1879220176 PK:null N /EC:176991315>, creator: > <DBUser@2069151341 PK:1000008 Name:'cl /EC:176991315> // > EC:er.extensions.eof.ERXEC@a8cac53 (FTS:4006.075 s) > 14:09:26.635 DEBUG evaluateExpression: > <com.webobjects.jdbcadaptor.FrontbasePlugIn$FrontbaseExpression: "SELECT ... > FROM "T_PRICE_OFFER" t0 WHERE t0."C_CREATOR_ID" = 1000008" withBindings: > > 14:09:26.643 DEBUG 181 row(s) processed > WEIRD 31 > ... > === > > and so forth: whenever I add a new price offer into the same user's 1:N > relationship, the price offers of that user get re-fetched again. > > I'm flabbergasted. Is this the normal WebObjects (or, rather, EOF) behaviour? > Am I missing something of importance? > > Thanks, > OC > > > _______________________________________________ > Do not post admin requests to the list. They will be ignored. > Webobjects-dev mailing list ([email protected]) > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/webobjects-dev/rgurley%40smarthealth.com > > This email sent to [email protected] _______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
