Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ORDER BY is slow
Message
De
11/03/2002 16:47:51
Mike Yearwood
Toronto, Ontario, Canada
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00631051
Message ID:
00631214
Vues:
26
How about select group by order by ?

No distinct?


>Hi Mike,
>
>>How many distinct records are being returned? If there are mostly distinct record, you'll be dealing with close to 100,000 records in the result. You could try this too..
>
>Only about 50-60 records are returned.
>
>>Create permanent unique index(es) for the particular field(s).
>>INDEX ON &lcField tag UNIQUE
>>
>>I don't expect you would want to do this index command each time <g>.
>
>I tried creating a UNIQUE tag, but it didn't help the SELECT with the ORDER BY.
>
>>Then
>>
>>SET ORDER TO TAG
>>SCAN
>> ...Update the treeview here...
>>ENDSCAN
>
>That's true. I could just do that... The frustrating thing is that the SELECT is blazing fast without the ORDER BY....
>
>Thanks,
>
>Steve
>
>
>>>Hi everyone,
>>>
>>>I need to do a SELECT DISTINCT from a table with about 100,000 records to populate the top level nodes of a treeview control, with the user able to select different fields to populate the treeview with.
>>>
>>>I have index tags on the fields that the user can specify and UPPER() of the same fields.
>>>
>>>The following query takes about 36 seconds:
>>>
>>>
SELECT DISTINCT &lcField FROM DocsMast ;
>>>   ORDER BY &lcField ;
>>>   INTO CURSOR TreeInit
>>>
>>>The following code runs in less than 1 second:
>>>
>>>
SELECT DISTINCT &lcField FROM DocsMast ;
>>>  INTO CURSOR TreeInit
>>>
>>>INDEX ON UPPER(&l_cField) TAG Sorted
>>>
>>>Why? Is there a way to get the result ordered without having to do a manual INDEX or wait for 30+ seconds? I gather that VFP is applying the ORDER BY to the entire table before applying the DISTINCT clause.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform