Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SELECT Statement
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00513062
Message ID:
00513329
Vues:
18
>>According to SYS(3054,1), you get partial Rushmore optimization using LIKE instead of and equal sign. Of course, you have to have an index tag on the expression used on the left side of the equation.
>
>Yep, I just tried:
>
>sys(3054,1)
>select * from lender where short like "A%" && Partial
>set ansi off
>select * from lender where short="A"
&& Full
>
>But why it's partial? It uses short index in both cases...

I ran a test of Like and Equal on a 3000 record table using the following code. My customer has an index on upper(city).
clear
lcAlpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for K = 1 to 5
   close tables all
   lnStart = seconds()
   for i = 1 to 100
      for j = 1 to 26
         cCity = substr(lcAlpha, j, 1)
         select * from customer where upper(city) = ?cCity ;
            into cursor crsTemp nofilter
      endfor
   endfor
   lnFinish = seconds()
   ?
   ? "Equal:", lnFinish - lnStart
   close tables all
   lnStart = seconds()
   for i = 1 to 100
      for j = 1 to 26
         cCity = substr(lcAlpha, j, 1) + "%"
         select * from customer where upper(city) like ?cCity ;
            into cursor crsTemp nofilter
      endfor
   endfor
   lnFinish = seconds()
   ? "Like:", lnFinish - lnStart
endfor
return
For 2600 iterations of the same SQL except for the parameter value, I got the following results in seconds:
Like     Equal
------   ------
28.183   27.830
28.164   27.857
28.114   27.867
27.951   27.876
27.951   27.857
28.005   27.994
28.117   27.971
28.186   28.195
28.188   27.903
28.176   27.853
The Like operation returns partial optimization, while the Equal operation returns full operation. YMMV.
Mark McCasland
Midlothian, TX USA
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform