Program: Superbase 4 Version: 1.3x Topic: Optimizing filters in queries Date: October 13, 1992 Summary : Filters in queries ( and updates ) can be considerably optimized. There are two levels of optimization: basic optimization ( always present ) and the use of SET QUERY ON to switch on full/advanced optimization. Basic Optimization accepts th e filter as is, and it analyses the filter from left to right, looking for any point in the filter where optimization will be BROKEN. If such a break occurs, further optimization attempts cease. In Advanced Optimization, Superbase does not necessarily reject a filter instruction line at the first point optimization is broken. Advanced Query Optimization attempts to resolve variables into literal values, convert functions and calculations to their result, handle multiple and outer join expressi ons and respect the OR operator. Further, Superbase may choose not to use a specific ORDER designation in a filter to access records, in preference to another indexed field in the filter that Superbase may decide will produce a quicker response. Rules for Basic Optimization 1. The index to be used for optimization must be the index that is being used by the selection commands. 2. Superbase scans from left to right looking for optimizable expressions. 3. Certain syntax elements such as OR, ( ) 's and FUNCTIONS stop this scanning at the place where they occur, and so should be put to the right of any optimizable expressions. 4. A maximum of two expressions can be optimized (but these must refer to the current index field and be linked with AND). 5. Superbase optimizes >, <, <=, >= and = (but apparently not > or < for text fields) and optimizes LIKE with simple wildcards (as long as it is of the form LIKE "text*", rather than LIKE "*text").