ISAM

Richard Gaskin ambassador at fourthworld.com
Sat Aug 20 11:04:39 EDT 2005


Scott Kane wrote:
> I think I'll look at saving stacks containing
> cards to an external file instead.

For very small data sets it's hard to beat the convenience of using 
cards.  But for anything above a few thousand records it can be cumbersome.

As with HyperCard, the inventor of this engine (Scott Raney) reminds us 
that the stack structure is not optimized for use as a database.  Dr. 
Raney suggests that you'll find serious performance degredation after 
about 5,000 records, and in my experience I find that to be true.

So if you need fewer than a couple thousand records then using cards may 
be a great option. But if you'll need more it may be useful to consider 
lists or custom properties.

To help you get an idea of the performance differences between these, I 
threw together a script that creates 5,000 records in each format, 
copied below. To run it:

1. Make a new stack
2. Make some fields (I used 7), group them,
    and turn on the group's backgroundBehavior
3. Paste the script below into a field

Here are the results (1GHz PowerBook, OS X 10.4, 768MB RAM):

Cards: 50860ms    List: 168ms    Props: 236ms

Saving the data shows a similar disparity of performance: stacks with 
large numbers of cards take an increasingly long time to save as the 
number of cards grows, disproportionate to the actual number of cards 
(not quite geometric, but certainly not linear).  But saving a stack 
file with one card and thousands of properties is very fast.

--
  Richard Gaskin
  Managing Editor, revJournal
  _______________________________________________________
  Rev tips, tutorials and more: http://www.revJournal.com


--------------------------------------------------------

on mouseUp
   put 5000 into n
   --
   -- Cards:
   lock messages
   lock screen
   put the millisecs into t
   repeat n
     create cd
     repeat with i = 1 to the number of flds
       put "dsgsdtg sdtg dwg dsg sdgsdg" into fld i
     end repeat
   end repeat
   put the millisecs - t into t1
   --
   -- List:
   global gData
   put empty into gData
   put the millisecs into t
   repeat n
     put empty into tRecord
     repeat  the number of flds
       put "dsgsdtg sdtg dwg dsg sdgsdg" &tab after tRecord
     end repeat
     put tRecord &cr after gData
   end repeat
   delete last char of gData
   put the millisecs - t into t2
   --
   -- Props:
   set the customproperties of this stack to empty
   put the millisecs into t
   repeat with i = 1 to n
     put empty into tRecord
     repeat the number of flds
       put "dsgsdtg sdtg dwg dsg sdgsdg" &tab after tRecord
     end repeat
     set the uMyData[i] of this stack to tRecord
   end repeat
   put the millisecs - t into t3
   --
   put "Cards: "& t1 &"ms    List: "&t2&"ms    Props: "& t3 &"ms"
end mouseUp




More information about the use-livecode mailing list