Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What are the best indexes to have for a filter ?
Message
De
11/01/2005 15:21:53
 
 
À
11/01/2005 12:58:50
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
00975956
Message ID:
00976134
Vues:
9
No, on the contrary, it's very fast! Notice that the first search is fully optimized, and the next searches are done in RAM. In my case I have a table with about 6 million records, and the search is always immidiate. In reality the total speed depends on how many records you get in the first SELECT. In my system I have a function to sort the laCondition array so the longest condition is in the first element, since this condition normally will get fewest records which is a plus.

>Yes, but since the question was about optimization: this might be fairly slow. I think execution might faster if you create a single variable with all the conditions - a little detail work, but not really difficult - and then use macro substitution in your SQL - SELECT command.
>
>>Hi Hilmar,
>>
>>I know that combining a variable number of ANDs can be tricky for filters, that's why I asked Franco about the possibility to use a cursor in stead. I discovered some years ago that you can SELECT from a cursor with the same name as your result cursor, which makes this very easy for cursors, given ALL the different conditions are ANDs:
>>*laCondition is an array of condition, each element is ONE legal condition, for instance "Department=1"
>>lcCondition=laCondition(1)
>>SELECT * FROM yourTable where &lcCondition INTO CURSOR yourResult ReadWrite
>>FOR x=2 to ALEN(laCondition)
>>  lcCondition=laCondition(x)
>>  SELECT * FROM yourResult where &lcCondition INTO CURSOR yourResult ReadWrite
>>ENDFOR
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform