APPX is the Premier Development and Runtime Environment for Business Application Software
(Answer) (Category) FAQ's - APPX Software, Inc. : (Category) APPX Utility : (Category) APPX Development Environment : (Category) Query Processes :
Why doesn’t my QUERY use the file’s index?
A query for (FLD EQ "A") used the index on FLD to select records, a query for (FLD EQ 1) OR (FLD EQ 2) OR (FLD EQ 3) doesn't use the index, why? (Determined by looked in APPX QUERY LOG and saw what it was doing.)

The Query compiler currently (as of 4.1.9) stops looking for indexes once it runs into an OR condition.

Bruce Johnston Feb 5, '04: Starting in 4.1 you can use the new Query Event Point, Establish PCF Range, to boost performance where OR conditions are on leading portions of a key field. In the following example, a memory file, MCUST, contains customer master record keys of interest obtained using a prior scolling input... ...
      *                                                                         
      *        Customer of interest were supplied in an earlier input.          
      *                                                                         
      BEG READ DAR MCUST                  HOLD 0 KEY IS  MCUST CUSTOMER NO      
      BEG AT   DAR TRANSACT IN DAR MCUST CUSTOMER NO                            
      END AT   DAR TRANSACT IN DAR MCUST CUSTOMER NO                            
      BEG READ DAR TRANSACT               HOLD 0 KEY IS  TRANSACT KEY           
      GOSUB    --- PROCESS QUERY RECORD                                         
      END READ DAR TRANSACT                                                     
      END READ DAR MCUST                                                        
... This is effectively an OR condition for each value of MCUST CUSTOMER NO. You could have additional OR conditions on other key fields by simply cloning the above sequence and then modifying it. I have verified Steve's assertion that you can't end up with the same record selected twice.
Note that the presence of ANY code in this series even something as innocuous as a simple TRAP or comment line will disable the Fast Query which might otherwise occur on design/runtime criteria normally specified though additional selection criteria are honoured. The records acted upon by --- PROCESS QUERY RECORD are simply the only candidates considered for the selection criteria.
[Append to This Answer]
2004-Feb-05 6:40pm
Previous: (Answer) Query stops before processing entire file!
Next: (Answer) Can I create a Cached copy of a file to use in my pre-user selection event point?
This document is: http://board.appx.com/cgi-bin/fom.cgi?file=338
[Search] [Appearance]
This is a Faq-O-Matic 2.719.
Copyright 2003 by APPX Software, Inc. All rights reserved.