User guide

Using ENFORM Search Statistics
Using ENFORM Efficiently
5–2 058058 Tandem Computers Incorporated
Figure 5-2 shows sample search statistics where both $mkt.sample.region and
$mkt.sample.employee indicate LEVEL READ as 1.
Figure 5-2. Search Statistics Where LEVEL READ = 1
SET @STATS TO ON;
OPEN region,employee;
LINK region TO employee VIA regnum;
LIST BY regname,empname;
FILE NAME LEVEL READ RECORDS READ POSITIONS
$mkt.sample.region 1 7 1
$mkt.sample.employee 1 55 1
003,06,022 BEGIN( 8/31/82 - 15:17:15:57) END ( 8/31/82 - 15:17:27:33)
STRATEGY COST = 3
The search statistics shown in Figure 5-2 occur because the query processor sets up a
special join strategy (a means of associating data from the two files) to search the two
files at the lowest level. In order for the query processor to set up a join strategy, the
two files must be sorted by the value of the linking fields. To retrieve the records
requested in the query shown in Figure 5-2, the query processor reads the first record
from $mkt.sample.region. The query processor then reads the first record from
$mkt.sample.employee. If this record matches the record from $mkt.sample.region, the
query processor builds a target record from the matching pair. The query processor
continues reading records in $mkt.sample.employee until the value of the linking field in
$mkt.sample.employee exceeds the value of the linking field in $mkt.sample.region.
The query processor then reads the next record from $mkt.sample.region If the linking
field in $mkt.sample.region is the same for the newly read record as for the previously
read record, the query processor rereads the records from $mkt.sample.employee for
which the linking fields match. For the query shown in Figure 5-2, no duplicate values
exist for the linking field in $mkt.sample.region because the linking field is the primary
key of that file. The query processor, therefore, reads $mkt.sample.employee until the
value of the linking field exceeds the value of the linking field in the current record
from $mkt.sample.region.
The query processor continues reading the two files in parallel until both files have
been read completely. A query that causes the query processor to use the join strategy
is desirable because each file is read only once.