Brian Smith wrote:
On Fri, 15 Nov 2002, Mark Wilden wrote:


One thing's missing: Requirements. :)

Are you sure a linear search for a name will be too slow? What do you
expect your insert/query ratio to be? What is the maximum amount of time
a user is willing to wait to look up something (if the user ever does)?

Well, the items will be listed by name in one view, so there definitely
needs to be a sort by that.  The linear search in that case would be by
the record ID, which would only be comparing UInt32 values that will
always be at the front of the record.  That search is only really required
when taking the IDs stored for linked records to list their names, and
looking up the record number to possibly go to a linked record (still
thinking over that one), and this may only happen when you go from the
list view to the record view.

That may not be so bad, actually, depending on how many records that are
in the database, but that could be quite a few.  It could be further
simplified by taking the list of record IDs and sweeping through the item
database once, finding the item names and record numbers corresponding to
each ID (in case one record is linked more than once).
Sort it by the UInt32 unique ID, then sort the names into the list in sorted order. I've done some testing and had reasonable performance with up to a couple hundred records. If you have more than this, then you'll need to keep them indexed, which isn't too hard so don't try avoid it at all costs.

Matt


--
For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/

Reply via email to