Salesforce

Using XREF Within Indexes Explained

« Go Back

Information

 
TitleUsing XREF Within Indexes Explained
URL Name21100
Article Number000139693
EnvironmentProduct: Progress
Product: OpenEdge
Version: All Supported Versions
OS: All supported platforms
Other: XREF, INDEX
Question/Problem Description
Use of the Compiler's XREF option to find what index or indexes are used in a query.
How to use XREF Compiler option to find what index or indexes are involved in a query?
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
To generate an xref report, run the following command in a Progress editor:
compile <ABL_sourcecode.p> save into <directory> xref <xreffile>
  • XREF specifies the file where the Application Compiler writes cross-reference information between source files and database objects.xref.
  • For each object reference, the .xref file contains one un-formatted and blank-separated line containing the following:
1) Procedure name
2) Source filename
3) Line number
4) Reference type
5) Object identifier

List of tags the XREF compile option generates:

SEARCH:
Indicates an index bracket or look up will be used.  The logical database name, table name, and index names are listed.  When multiple brackets and indexes are used for the same query, there will be one search line for each bracket.

SEARCH ... WHOLE-INDEX:
Indicates that a suitable bracket could not be constructed and an index scan over the entire table will be performed using the index noted. The following Article expands on this topic:
SORT-ACCESS:
Indicates that the query result is to be ordered by a particular column value and no suitable index exists.  A sort of the query result on the noted column value is required. The following Article provides an example:
ACCESS:
Indicates that the specified table and field value is used at this point in the program.

CREATE:
Indicates that a record is created at this location in the program.

DELETE:
Indicates that a record is deleted at this location in the program.

UPDATE:
Indicates that the specified field value of a table is updated at this location in the program.

Refer to the COMPILE statement in the Progress Language Reference for more information on the cross-reference file.

Which Indexes are Used

To learn what index or indexes the compiler will use, COMPILE with the XREF option.  This creates a cross-reference listing with a SEARCH label indicating which indexes will be used.  The presence of multiple SEARCH labels for the same statement indicates that multiple indexes or brackets will be used for the query.
Example 1: The internal Recid (Rowid) is used directly, no index is used
FIND customer WHERE (ROWID(customer) = rowid-customer).
/* XREF:   SEARCH tmp.Customer RECID  */
 
Example 2:    Index CustNum is used.
FIND customer WHERE (custnum = 46) USE-INDEX custnum.
/* XREF:   SEARCH tmp.Customer CustNum */

Example 3:    Index Name is used.
  • WHOLE-INDEX after the index Name indicates that no bracketing is possible.
  • No bracketing also means that the entire index is bracketed.
  • This will result in a full index scan, reading every index entry, to retrieve the rows which is costly.
FIND customer WHERE (custnum = 46) USE-INDEX Name.
/* XREF:   SEARCH tmp.Customer Name WHOLE-INDEX */

Example 4: Index CustNum is used.  
  • WHOLE-INDEX after the index name indicates that no bracketing is possible.
FOR EACH customer:
/* XREF:   SEARCH tmp.Customer CustNum WHOLE-INDEX */

Example 5: Two entries with the SEARCH label appear in the XREF listing for the same listing statement number.  
  • This indicates that two indexes, Name and SalesRep are being used.
FOR EACH customer WHERE (name = "Martin") AND (Salesrep = "Jim"):

/* XREF:   SEARCH tmp.Customer Name
        SEARCH tmp.Customer SalesRep */

Example 6:     Three entries with the SEARCH label appear in the XREF listing for the same listing statement number.  
  • In this case index Custnum and Name are used.  
  • Name appears twice indicating that two separate brackets on Name are used.
FOR EACH customer WHERE (custnum < 99) OR (name = "John") OR (name = "Martin"):

   /* XREF:   SEARCH tmp.Customer CustNum
                   SEARCH tmp.Customer Name
                   SEARCH tmp.Customer Name */

 
Workaround
Notes
References to Other Documentation:

Use ABL Database Triggers and Indexes: Database Index Usage, Find out which indexes are used
https://docs.progress.com/bundle/openedge-abl-database-trigger-and-indexes/page/Find-out-which-indexes-are-used.html  

Progress Article:

 Row Retrieval Process Explained  
Keyword Phrase
Last Modified Date5/20/2022 6:46 PM

Powered by