# Search Method

The search method specifies how the system will look for data stored in the table when that table is used by a program. The search options are listed in Table 156.

Table 156. Table Search Options

Option

Search Method

S

Serial

Q

Queued

B

Binary

C

Bounded Binary

H

Hash

##### Serial (S)

The serial search starts with the first row in the table and moves consecutively through the rows until a match is found or the end of the table is reached. The average retrieval time for a random set of keys increases linearly with table size. In a user ordered table, where rows can be ordered by frequency of access, the serial search may be the fastest search.

Serial search is also the fastest search method for small tables (less than 15 rows) where more complex searches do not justify extra computational requirements.

##### Queued (Q)

The queued search method is a variation of the serial search. Each subsequent search begins where the previous one left off. The search finishes when a match is found, the key is out of range or the end of the table is reached. This method works only with sequential or descending sequential tables.

When attempting to align table data for an ordered data source or for a merge operation with two tables that are organized in the same way, this search method may be the most efficient available. Queued is the only method that allows you to take advantage of the ordering of both tables.

##### Binary (B)

This search method compares the key of a row to the middle row of an ascending sequential or descending sequential table to determine which half of the table contains the row. The search then divides that half into half once again. It continues this process of dividing the remainder in half until the row is found. This method provides fast access and updating of sequentially organized tables.

##### Bounded Binary (C)

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 (S).

##### Hash (H)

A Hash search method is only used to search a table with a Hash organization. Since the rows in a Hash table are stored based on an arithmetic operation, that same operation is used in the search to determine the location where the row will be found. The Hash search method is very fast if you have a large table.