Soups

When to Use an Index

There are two clear cases in your soup design where you should use an index:

There are other cases where you might need to search, but using an index will be of no help. This occurs if the set of valid entries does not share a common index value or range of index values. For example, imagine trying to find all entries whose age multiplied by weight exceeds their height multiplied by shoe size. No index will help find exactly those entries (unless you have the weirdly constructed and very specialized index on the integer slot ageTimesWeightMinusHeightTimesShoeSize). Barring such unusual types of requirements, you can do a great deal to improve soup performance by carefully choosing which slots in a soup will be indexed. Just remember the following as a general rule:

Unfortunately, indexes are not free, so it will not make sense to index on every slot in a soup. Indexes take up space in the soup and make adding, deleting, and modifying entries slower.


An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.

Last modified: 1 DEC 1996