• 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: Binary primary keys
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binary primary keys


  • Subject: Re: Binary primary keys
  • From: David Avendasora <email@hidden>
  • Date: Tue, 1 Dec 2009 10:56:35 -0500


On Dec 1, 2009, at 10:41 AM, Jeff Dunnett wrote:

Anjo,

Well the idea is to select a single primary key and then yes it to quickly delete a large number of records from a table.  

Using SQL query like this: 

DELETE FROM "cms"."ms_contestant" WHERE contest_id = (SELECT contest_id FROM "cms"."ms_contestant" WHERE contest_event = '2009 Contest');

Rather then WebObjects code like this:

NSArray contestants = contest.contestants();

for(int i = 0; i < contestants.count(); i++){
Contestant contesant = (Contestant)contestants.objectAtIndex(i);

ec.deleteObject(contestant);

}

Well, that seems like the hard way.

How about: 

contest.deleteAllContestantRelationships();

That will do basically what you've written above, but it's one line of code and will properly handle both sides of the relationship.

Or, if the contestant() relationship on Contest either Owns Destination or has a Cascade delete rule:

ec.deleteObject(contest);

I'm not sure what the SQL will look like for that though.

Are you running into performance problems, or simply anticipating them?

Dave


 _______________________________________________
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

References: 
 >Re: Binary primary keys (From: Jeff Dunnett <email@hidden>)

  • Prev by Date: Re: Binary primary keys
  • Next by Date: Re: [OT] Leaving WO
  • Previous by thread: Re: Binary primary keys
  • Next by thread: Re: Binary primary keys
  • Index(es):
    • Date
    • Thread