The tableBASE software offers you a variety of search methods that are optimized for performance, table organization, and in-memory use:
The search is applied to the Index and the Index then points to the appropriate row of the Data Table.
Serial search
A serial search compares the search key with the key of each row in the Index. The search begins at top of the Index and progresses through the Index until the row is found that contains the search key or until all rows in the Index have been examined.
A serial search uses little overhead and is the fastest search method for small Indexes. It is also more efficient for user-controlled Indexes with a skewed frequency of hits. The user can place the most frequently accessed rows at the top of the Index.
The table organization must be Random or User-controlled sequence.
Queued sequential search
This search method is executed by progressing serially through the Index and comparing the search key to each Index key until a row is found. Subsequent searches begin where the last row was compared, if the search key is farther along in the Index sequence. If the key of the next row examined is too high (or too low for descending sequential Indexes), the search resets to start from the beginning of the Index.
Queued sequential searches are faster on partially-sequenced or mostly-sequenced data—for example, transaction matching in a master file type of update process.
The table organization must be ascending or descending Sequential.
Binary search
The search key is compared with the key in the middle of the Index and determined to belong to either the top or bottom half of the Index. It is then compared to the middle of the appropriate half of the Index. This process of splitting the remaining Index rows in half continues after each comparison until the desired row is found.
The table organization must be ascending or descending Sequential.
Bounded binary search
The bounded binary search process compares the search key to the endpoints of an Index to determine if the search key is within the Index range. If the search key is not within the range, then the system returns a “not found” message. If the search key is within the range, then a binary search process is used to find the key position.
A bounded binary search is a fast technique for performing inserts into ordered data.
The table organization must be ascending or descending Sequential.
Hash search
This searching technique randomizes the key to calculate the location of a row in the table. A hash search is the best search method for large tables that are usually accessed randomly. Performance is enhanced because there is no search looping, however this creates greater software overhead because of the calculation required for the search.
Under normal circumstances hash searches and hash-based insertions use less CPU time than binary, serial, and most sequential searches, and require fewer page accesses than any other search.
Space utilization is minimized by a Hash Pointer Table—the actual data is kept in a densely packed random table, while the more sparsely packed Index contains only the address of the data rows.
The table organization must be Hash.
Search summary
Table 59 summarizes the valid combinations of table organizations and search methods allowed by tableBASE.
Table organization |
Search methods |
||||
---|---|---|---|---|---|
Queued sequential |
Bounded binary |
Binary |
Serial |
Hash |
|
Sequential |
Y | Y | Y |
|
|
Descending sequential |
Y | Y | Y |
|
|
User-controlled sequence |
|
|
|
Y |
|
Random |
|
|
|
Y |
|
Hash |
|
|
|
|
Y |