Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- SIx Driver RDD v3.00 - Reference Guide - <b>m6_isoptimize():</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
  m6_IsOptimize():

  Purpose:  Used to measure the optimizability of a FILTER/FOR condition.

   Syntax:  m6_IsOptimize( <cForExpr> [, lIsCount] )

    Where:  <cForExpr>  --  FILTER/FOR condition criteria to be evaluated.
                            (Must be a character expression)

            [lIsCount]  --  Optional.  Value of .T. specifies that the query
                            condition should be tested against the stricter
                            COUNT query requirements.  See Notes below for
                            the differences.

  Returns:  Measure of optimization.  Return values range from 0 - 2, with
            two being fully optimizable.  Use the following constants
            defined in "MACHSIX.CH" to interpret the return values:

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


    Notes:  Use m6_IsOptimize() to determine the optimizability of the
            FILTER/FOR condition prior to executing an optimizable command.
            An expression may be deemed not optimizable for any of the
            following reasons:

               .  No database in use
               .  No indexes in use
               .  Database exceeds 524 million records
               .  Error in query condition. Check m6_Error().
               .  No matching indexes found in FILTER/FOR criteria
               .  FOR criteria contains LOCAL or STATIC variables
               .  Extended expression used in FILTER/FOR criteria
               .  Workarea not using a supported RDD
               .  Matching key found, but in RYO, UNIQUE, or CONDITIONAL
                  index, other than the current index order.

            If a query is found to be not optimizable a reason code can be
            retrieved with the m6_Error() function.

            The difference between an optimization test for a COUNT query
            and any other command 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 and no
            database access required.  Therefore, not only must every
            expression match up to an index key, but also deleted records
            (if DELETE is ON) must be eliminated by an index built on
            DELETED().  For more details about optimizing deleted records
            see the discussion in Performance Tips in the USING
            part of this guide.


  Example:

         #include "SIXCDX.CH"
         #include "MACHSIX.CH"

         LOCAL nSel := 0, dStart, dEnd, cFor

         USE Names INDEX Name, Salary, State, Date

         //..............................................fully optimizable
         ? m6_IsOptimize( 'last = "Hewson"')                       //....2

         //........ ....partially optimizable - at least one indexed field
         ? m6_IsOptimize( 'state = "CA" .and. zip = "92656" ')    //.... 1

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

         //............................not optimizable - no indexed fields
         ? m6_IsOptimze('age = 21 .and. zip = "28105"')           //.....0
         ? m6_Error()                                                 //..2009

         //............not optimizable - extended expression used for alias
         nSel := select()
         ? m6_IsOptimze( '(nSel)->state = "CA" ')                 //.....0
         ? m6_Error()                                                 //..2019

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

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

         //...............fully optimizable - locals expressed as constants
         cFor := "date >= ctod('"+ dtoc( dStart ) + "') .and. " +;
                 "date <= ctod('"+ dtoc( dEnd   ) + "')"
         ? m6_IsOptimize( cFor )                                   //.....2


         Function MyUdf()
           .
           .
           .
         Return ( .T. )


See Also: m6_Error() Performance Tips

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