Effects of Screening Conditions on Retrieval

In this section:

If a record in a segment fails a record selection (IF) test, the corresponding records in descendant segments are not retrieved.

To increase I/O efficiency, place a record selection test at a higher level in the file structure. This restricts the number of records that have to be tested.


Top of page

Example: Using Selection Criteria on Parent Segments

Suppose this request is entered against the structure EMPSS01 (the corresponding Master File is EMPFULL).

TABLE FILE EMPFULL
COUNT EMP_ID AS 'NUMBER OF EMPLOYEES'
BY OFFICE_CODE AS 'OFFICE CODE'
IF DEPT_NAME EQ 'PERSONNEL'
END

The output is:

OFFICE CODE  NUMBER OF EMPLOYEES
-----------  -------------------
002                            4

Every time a record in segment DEPT has a value in the DEPT_NAME field not equal to PERSONNEL, the corresponding records in descendant segments EMPLOYEE and OFFICE are ignored, and the next record in segment DEPT is retrieved. In addition, when IF criteria on a lower segment fail, the row is removed from the internal matrix.


Top of page

Example: Using an IF Test on a Descendant Segment

Assume a subtree has four segments:

The following example illustrates how to list all employees who are programmer/analysts:

TABLE FILE EMPFULL                   
PRINT TITLE AS 'TITLE'               
BY DEPT_NAME AS 'DEPARTMENT'         
BY EMP_LAST_NAME AS 'LAST NAME' IN 25
BY EMP_FIRST_NAME AS 'FIRST NAME'    
IF TITLE IS 'PROGRAMMER/ANALYST'     
END                                  

The output is:

DEPARTMENT              LAST NAME        FIRST NAME  TITLE             
----------              ---------        ----------  -----             
INTERNAL SOFTWARE       DOUGH            JANE        PROGRAMMER/ANALYST
                        GALLWAY          JAMES       PROGRAMMER/ANALYST
                        GRANGER          PERCY       PROGRAMMER/ANALYST
                        HEAROWITZ        VLADIMIR    PROGRAMMER/ANALYST
                        JENSEN           JULIE       PROGRAMMER/ANALYST
                        O'HEARN          KATHERINE   PROGRAMMER/ANALYST

For this request with only one IF test, FOCUS retrieves each DEPT record, each EMPLOYEE record for a given DEPT, each EMPOSIT record for a given EMPLOYEE record, and the JOB record connected to each EMPOSIT. After retrieval, FOCUS determines whether to print the record from the value of the TITLE field.


Top of page

Example: Using Multiple IF Tests to Reduce I/O

The following example produces the same output as the example in Using an IF Test on a Descendant Segment. In this company, only the Internal Software department has programmer/analysts working for it. Therefore, adding an additional IF test on the parent segment (DEPT) reduces the number of descendant segments retrieved:

TABLE FILE EMPFULL                    
PRINT TITLE AS 'TITLE'                
BY DEPT_NAME AS 'DEPARTMENT'          
BY EMP_LAST_NAME AS 'LAST NAME' IN 25 
BY EMP_FIRST_NAME AS 'FIRST NAME'     
IF DEPT_NAME IS 'INTERNAL SOFTWARE'   
IF TITLE IS 'PROGRAMMER/ANALYST'      
END                                   

Now records are only retrieved and tested when the DEPT_NAME field equals the value INTERNAL SOFTWARE.


Top of page

x
Restricting the Number of Records Retrieved

How to:

Another method used to increase efficiency is to restrict the number of records retrieved. You can always limit the number of records retrieved from the IDMS data source, and/or the number of records that FOCUS accepts, with READLIMIT and RECORDLIMIT tests. Add one or both of these IF criteria to your request.



x
Syntax: How to Place a Limit on Records Retrieved
IF READLIMIT IS number 
IF RECORDLIMIT IS number 

Tip: These criteria can be assigned to your password as part of file security through the FOCUS DBA facility.

A third method that increases efficiency is file inversion. See File Inversion for more information.


Top of page

x
Screening Conditions With Unique Segments

If a record in a unique segment fails a selection test, its parent is rejected and the next record of the parent segment is retrieved. For example, in the following figure if a record in non-unique segment C fails an IF test, the next record in segment C is retrieved. Only if all C records for a given A fail the test is the A record rejected. When a record in unique segment D fails a test, the parent B record is rejected and the next record in segment B is retrieved. When a record in the entry A segment fails a test, FOCUS retrieves the next A record, even if the entry segment is defined as unique:


Information Builders