Previous Topic

Next Topic

Alternative Key Types

c-tree Plus supports a number of basic key types:

  • fixed length keys (type 0);
  • leading character compression (type 4);
  • padding compression (type 8);
  • leading/padding compression (type 12, a combination of types 4 and 8).

Normally you will use fixed length keys. If there is a reasonable amount of duplication in the leading characters of the key values, you can decrease the size of your index file by choosing leading character compression. If your key lengths vary in size you may find that padding compression will decrease your index size (remember that you should be padding keys to the same length). Key type 12 combines both types of compression. With compound (multi-segment) keys, c-tree Plus builds the complete key value (for keylen bytes), then applies the compression logic. For this reason, only the last segment can be compressed.

Using one or both of the compression modes increases the CPU time to process a key since the key values must be compressed and expanded, and the key values cannot be located at fixed positions within the node. The increased CPU time is eventually offset by the reduced disk head movement due to the reduced size of the index. As the index grows, the compression can lead to fewer levels in the tree structure, compared with a fixed length tree, because of the increase in branching, due to more keys in each node. A reduction in the number of levels leads directly to a reduction in the number of disk accesses.

Note: Key compression imposes a significant performance impact, especially when deleting records. Use this feature only when absolutely necessary to keep index space requirements to a minimum.

Leading character compression and padding compression each require a byte to store the extent of the compression. The maximum key length compressed is restricted to 255. Keys of greater length will only have compression applied to the leading and/or trailing 255 bytes. Further, employing the compression modes when no compression is possible will cause wasted storage since the bytes used to note the extent of the compression will be stored in addition to the key values.

The default padding character is an ASCII blank (20 hex). This can be changed for a particular index file by using the SetVariableBytes() function. See SetVariableBytes in the c-tree Plus Function Reference Guide for more details.