Re: can I use fetch spec to filter an array? - WAIT I go ir
Re: can I use fetch spec to filter an array? - WAIT I go ir
- Subject: Re: can I use fetch spec to filter an array? - WAIT I go ir
- From: Chuck Hill <email@hidden>
- Date: Thu, 01 Jan 2004 11:37:27 -0800
Hi,
At 08:47 PM 01/01/2004 +1300, Denis Stanton wrote:
>
>On Thursday, January 1, 2004, at 07:03 PM, Paul D. Yu wrote:
>
>> Have you turned on -EOAdaptorDebugEnabled YES to take a look at how
>> many SQL statements are getting generated in your fetch on Bookings or
>> Agents?
>
>> So how many SQL statements are you generating for the Agent query?
>
>The trace ran to 7800 lines (or 22,751 with wrapping on), before I even
>got to select any agents.
>
>This may be more data than I can analyze.
>
There is a better way. I've posted an example here:
http://wodev.spearway.com/cgi-bin/WebObjects/WODev.woa/wa/Main?wikiPage=Turn
SQLLoggingOnAndOff
>first comment - I'm appalled at the amount of SQL it takes to generate
>the standard menus on my web page! My clever logic to make the
>selection of menu items offered dynamic depending on the access rights
>of the particular user is causing a lot of db access I didn't know
>about.
>
Are you doing fetches or following relationships? A fetch will always go
to the DB. Following a relationship will only do this the first time. If
you are using child or peer editing contexts on the pages you should
consider putting the menu/access rights logic in the session's default
editing context so that it can be loaded once and resused.
>Apart from that overhead, the second pass consists of precisely three
>SQL requests. Each gets a bunch of agents, (I select agents for each
>of three currencies.). The significant thing is that there are NO more
>SQL requests for bookings.
>
I take it that these are the result of explicit fetches.
>The first pass was a different story. Even though 6,700 bookings are
>read at the start it seems that each booking is then each being read in
>again later when required.
>
Something is wrong here. If you have fetched the Booking objects into the
same ec then faults for this will have already been fired. Are you using
manual fetches for this?
>This could probably be improved with a
>restructure of the program sequence as suggested by Chuck. I was
>hoping that pre-fetching all the bookings would save db accesses later,
>even with the agent-first algorithm. Either I've missed soemthing or EO
>is not clever enough to figure out that it already has all the bookings.
>
I suspect that you are doing something you are not mentioning, or something
that you don't realize. Once an object is in an EC, EOF will not go back
to the DB unless you explicitly tell it to.
>I didn't mention it before, but a booking may have many other
>relationships and these must also be followed to perform the
>calculations.
>
OK, now that might be a problem if these are not shared across bookings.
Things like currency that are really lookups will not be bad, they will
only result in a fetch per value. Take a look at the docs for
EOFetchSpecification and the method setPrefetchingRelationshipKeyPaths.
You should be able to bulk fetch these object on a one fetch per Entity basis.
>Thanks for you interest. No I have to worry about all the extra SQL
>I've been causing
>
I find this an interesting topic. I'm also curious as to where all that
SQL is coming from.
Chuck
--
Chuck Hill email@hidden
Global Village Consulting Inc. http://www.global-village.net
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.