Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Advantage CA-Clipper Guide v5.5 - aofisoptimizable() http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 aofIsOptimizable()
 Determines the optimization level possible for a filter expression
------------------------------------------------------------------------------

Syntax

     aofIsOptimizable( <cExpr> [,<lCount>] ) -> numeric

     <cExpr>  The character expression to be evaluated

     <lCount>  Optional logical value that specifies if the
     expression should be tested against the stricter COUNT query
     requirements. See Note below for the differences.

Returns

     Return a numeric 0, 1, or 2 indicating the level of optimization
     possible. Use the following constants defined in "AOF.CH" to
     interpret the return values:

     #define OPT_FULL           2  // fully optimizable
     #define OPT_PARTIAL        1  // partially optimizable
     #define OPT_NONE           0  // not optimizable

Description

     Use aofIsOptimizable() to determine the optimizability of an
     expression. An expression may be deemed not optimizable for any of
     the following reasons:

     -  No table in use
     -  No indexes in use
     -  Database file exceeds 524 million records
     -  No matching indexes found in expression criteria
     -  Expression contains LOCAL or STATIC variables
     -  Extended expression used
     -  Work area not using a supported RDD
     -  Matching key found, but it is in a CUSTOM, UNIQUE, or CONDITIONAL
        index

     If a condition is found to be not optimizable, aofErrorCode() will
     return information on why the expression is not optimizable.

     Note:  The difference between an optimization test for a COUNT
     query only pertains to the full optimization test. In order for a
     COUNT query to be fully optimizable, the entire query condition must
     be satisfied in the indexes. Therefore, not only must every
     expression match up to an index key, but deleted records (if DELETE
     is ON) must also be eliminated by an index built on DELETED().

Example

     LOCAL nSel := 0, dStart, dEnd

     USE Names INDEX Name, Salary, State, Date

     // Fully optimizable
     ? aofIsOptimizable( 'last = "Hewson"')                      // 2

     // Partially optimizable - at least one indexed field
     ? aofIsOptimizable( 'state = "CA" .and. zip = "83713"' )    // 1

     // Partially optimizable - at least one indexed field
     ? aofIsOptimizable( 'empty( salary ) .and. MyUdf()' )       // 1

     // Not optimizable - no indexed fields
     ? aofIsOptimizable( 'age = 21 .and. zip = "28105"' )        // 0

     // Not optimizable - extended expression used for alias
     nSel := select()
     ? aofIsOptimizable( '(nSel)->state = "CA" ' )               // 0

     // Fully optimizable - state field follows alias for this area
     ? aofIsOptimizable( 'names->state = "CA" ' )                // 2

     // Not optimizable - local variables
     dStart := ctod( "08/01/92" )
     dEnd   := ctod( "08/31/92" )
     ? aofIsOptimizable( 'date >= dStart .and. date <= dEnd ' )  // 0



Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson