• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Some help with Optimization
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Some help with Optimization


  • Subject: Re: Some help with Optimization
  • From: Art Isbell <email@hidden>
  • Date: Thu, 9 Feb 2006 14:11:28 -1000

On Feb 9, 2006, at 1:00 PM, Owen McKerrow wrote:

	public PersonName activeName()
	{
		int i;
		PersonName theName= null;
		for (i=0;i<personNames().count();i++) {
			PersonName temp = (PersonName)personNames().objectAtIndex(i);
			if ( temp.active().intValue() == 1 ) {
				theName = temp;
				break;
			}
		}
		return theName;
	}

Is there an easier/quicker way to do this ?

Rather than iterate through personNames, I would typically filter personNames using a qualifier that tests for active equals new Integer (1). I have no idea which approach, on average, would be faster.


System.out.println("Get Authors :" + new NSTimestamp());
NSArray tempAllExs = (NSArray) EOUtilities.objectsWithFetchSpecificationAndBindings (ec,"External","allMembers",new NSMutableDictionary());
System.out.println("Get names via value for key :" + new NSTimestamp ());
selectableExtenals = (NSArray)tempAllExs.valueForKey("activeName");
System.out.println("End :" + new NSTimestamp());


Which results in :

Get Authors :2006-02-09 21:50:46 Etc/GMT
Get names via value for key :2006-02-09 21:50:47 Etc/GMT
End :2006-02-09 21:50:57 Etc/GMT

As you can see there's 10 seconds to do the valueForKey bit.

Turning on SQL logging and I find that when I do the valuforKey look up its going back to the DB to get all the names.

I typically batch fetch rather than batch fault:

NSArray tempAllExs = EOUtilities.objectsWithFetchSpecificationAndBindings(ec, "External", "allMembers", NSDictionary.EmptyDictionary);
EOModelGroup defaultGroup = EOModelGroup.defaultGroup();
EODatabaseContext databaseContext = EODatabaseContext.registeredDatabaseContextForModel (defaultGroup.modelNamed("ModelName"), ec);
databaseContext.batchFetchRelationship(defaultGroup.entityNamed ("External").relationshipNamed("activeName"), tempAllExs, ec);
selectableExtenals = (NSArray)tempAllExs.valueForKey("activeName");


Anyways 10 seconds still seems like a long time even if it does need to get the info from the DB.

I have no idea whether my suggestions will accelerate your app, but they'd be worth a quick try. Also, you should ensure that the DB columns involved are indexed.


Aloha,
Art

_______________________________________________
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


  • Follow-Ups:
    • Re: Some help with Optimization
      • From: Chuck Hill <email@hidden>
    • Re: Some help with Optimization
      • From: Owen McKerrow <email@hidden>
References: 
 >Some help with Optimization (From: Owen McKerrow <email@hidden>)

  • Prev by Date: Re: Further: Some help with Optimization
  • Next by Date: Re: Some help with Optimization
  • Previous by thread: Re: Further: Some help with Optimization
  • Next by thread: Re: Some help with Optimization
  • Index(es):
    • Date
    • Thread