Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Selecting X TOP records
Message
De
11/10/2004 11:55:42
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00950435
Message ID:
00950457
Vues:
15
>Am I correct in assuming that when you use SQL Select, the TOP syntax is not optimized for an index?
>
>I have a table MYORDERS with field ORDERNO that has index tag.
>
>When I try:
>
>
>select top 10 * from MYORDERS order by ORDERNO
>
>
>The query takes considerable time. I can sort of "see" that VFP selects all records and then selects 10 from the top. Is there a way to make this query run faster?
>
>Thank you.

Yes, DISTINCT, ORDER BY and GROUP BY are not optimized.

Use a ordered SCAN + buffer + INSERT
* General fields are not supported
SELECT * FROM MYORDERS WHERE .F. INTO CURSOR result READWRITE
USE MYORDERS AGAIN ORDER TAGORDERNO
SCAN NEXT 10
    SCATTER MEMO TO aBuffer
    INSERT INTO result FROM ARRAY aBuffer
ENDSCAN
USE
SELECT result
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform