• 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: Best Design Practice
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best Design Practice


  • Subject: Re: Best Design Practice
  • From: Owen McKerrow <email@hidden>
  • Date: Thu, 13 Apr 2006 09:59:59 +1000

Further question.

Say you go to the database not realizing that the objects are already cahced, does WO then just do the sort and filter on the these cahched objects in memory ?
What happens if you have 1/2 the objects in memory and the other 1/2 still need to be retrieved from the DB ? Who does the sorting and filtering then ? I would assume that if the cached objects are still considered "fresh" by WO then it would get the other objects from the DB and do it in memory. Otherwise it would have to update the objects it already has in memory, with the ones returned from the DB. And does this apply no matter how many objects are cached. Say you have 1 object cached, what happens then ? Indeed how does WO know that one of the requested objects is already in cache ? Does it apply you query against the EODatabaseContext ( I think thats the one that stores the snapshots and stuff ) before going to the DB ? Or does it always go to the DB ?


Owen McKerrow
WebMaster, emlab
Ph : +61 02 4221 5517
http://emlab.uow.edu.au

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'The test of a first-rate intelligence is the ability to hold two opposed ideas in the mind at the same time and still be able to function.'
-F.Scott Fitzgerald,



On 13/04/2006, at 9:25 AM, Sacha Michel Mallais wrote:

On Apr 12, 2006, at 4:09 PM, Owen McKerrow wrote:

I have been using the first method but after talking with a college yesterday Im wondering if the second way may be quicker.
The in-memory will stil require a trip( or several to the DB ) to get the position sets, and then have to do the sort in memory once they get back. But if I have set the relationships Batch Faulting size, would these objects not already be in memory and thus we then cut down on the trip to the DB ?

It really is dependant on the state of your object store. If you have to go to the database to get the data, sorting at the database will almost always be preferable, particularly if you have an index on the sorted column (which turns sorting from O(nlogn) to O(1)). However, if your objects are already in memory, sorting in memory will almost always be preferable, simply because going to the database is expensive. With a large dataset (10s of 1000s of rows at least) in which you only intend to show the first few rows, you're almost always better off going to the database because sorting time will overshadow communication time with the database...


HTH,


sacha


-- Sacha Michel Mallais 800 kg gorilla Global Village Consulting Inc. http://www.global-village.net/ PGP Key ID: 7D757B65 AIM: smallais 1. Never tell everything at once. -- Ken Venturi, Ken Venturi's Two Great Rules of Life




_______________________________________________ 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: Best Design Practice
      • From: Chuck Hill <email@hidden>
References: 
 >Best Design Practice (From: Owen McKerrow <email@hidden>)
 >Re: Best Design Practice (From: Sacha Michel Mallais <email@hidden>)

  • Prev by Date: Re: Best Design Practice
  • Next by Date: Re: Best Design Practice
  • Previous by thread: Re: Best Design Practice
  • Next by thread: Re: Best Design Practice
  • Index(es):
    • Date
    • Thread