Re: Lots of EOs slow down the performance
Re: Lots of EOs slow down the performance
- Subject: Re: Lots of EOs slow down the performance
- From: Hugi Thordarson <email@hidden>
- Date: Wed, 5 Nov 2008 11:51:48 +0000
EOs come with a lot of overhead and creting them is quite expensive,
so the best solution in your case is probably to switch to raw row
fetching.
Raw row fetching works like normal fetching, except that what you get
back is an array of NSDictionaries, rather than EOs with their
associated overhead. Just change your fetch specification like this:
------
fs.setFetchesRawRows( true );
fs.setRawRowKeyPaths( [an array of keypathsto fetch] )
------
Example (ouch... - it's been a long time since I've written non-Wonder-
code):
------
EOFetchSpecification fs = new EOFetchSpecification( "Person", null,
null );
fs.setFetchesRawRows( true );
fs.setRawRowKeyPaths( new NSArray<String>( new String[] { "name",
"address" } ) );
NSArray people = someEditingContext.objectsWithFetchSpecification( fs );
for( NSDictionary person : people ) {
System.out.prinlnt( person );
}
------
One thing to beware of when using raw rows is that attributes with a
value of "null" will contain NSKeyValueCoding.NullValue instead, so
make sure your code can accommodate that (if you get a
ClassCastException when you switch to raw rows, you're probably
getting burned by this).
Cheers,
- Hugi
// Hugi Thordarson
// http://hugi.karlmenn.is/
On 5.11.2008, at 09:56, Yung-Luen Lan wrote:
Hi,
There is a task has be done in my wo app: creating thousands of (about
200,000) EOs and generating a csv file containing the information for
download.
When I create only 1000 EOs, it's fine. But if I create over 20,000
EOs, my page was kill due to no response after 30 secs. So there are
EOs created but no csv to download.
I checked the code, EO generating is fast. The problem is CSV
component. It's just a WORepetition with some WOString that reads the
EO's property directly.
I have no idea why it take so long to handle 200,000 EOs. (The result
file may exceed 5MB, however that's small in 21 century.)
How could I improve the performance? Or at least let my page won't be
killed after 30 secs.
(so I could wait for the csv to be generate.)
Regards,
yllan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden