How to BUILD "forests" tree by tree

You'll often want to index one data file more than one way, using more than one B-tree for the data file. When it comes time to BUILD multiple B-trees for the single data file, try creating one whole B-tree before building the next B-tree.

For example, the BUILD program in BTP/Branches #1 CALLs BTPINS three times after each READ in order to insert an item ID into three B-trees. A better approach is to first do all the inserts for the first B-tree, reselect and read the data file and do all the inserts for the second B-tree, then reselect and do all the inserts for the last B-tree. That way, different B-trees don't all compete for memory at the same time, thrashing is reduced during execution, and BUILD tends to run a little faster. If a BUILD is unexpectedly interrupted, one or more B-trees will probably already be done and won't have to be rebuilt. It's also a good idea to only BUILD the first thousand or so B-tree entries for the data file the first time a new B-tree is created, so the B-tree can be inspected and tested for correctness before waiting for a complete BUILD on the whole data file. And remember to avoid indexing null keys, as mentioned in BTP/Branches #2.