Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Inner working of SQL-Select with Group By
Message
De
21/03/2006 02:29:18
 
 
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 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01105965
Message ID:
01106114
Vues:
20
>>>Hi everybody,
>>>
>>>Does anyone know whether VFP Select-SQL with Group By option creates a temp result set without group by first and then performs GROUP BY? Or how exactly GROUP BY works?
>>>
>>>Here is the reason I'm asking:
>>>
>>>I had select sql that returned data as a temp cursor, then I performed Group By on it to obtain results I wanted. I then figured out, that I don't need this intermediate cursor and I better would do Group By in this cursor right away. I was expecting a performance gain by doing so. However, I don't seem to have this performance gain. I haven't measured the times (my mistake, since I can not revert the code that easily), but I have an impression that speed is the same or even worse.
>>>
>>>Thanks in advance for your input.
>>
>>GROUP BY is not optimizable
>
>Ok, what is better then:
>
>select cTrans_pk, cUserID, cUsGrLink_pk, yBalance from ... where ... into cursor curTemp
>
>select count(cTrans_pk) as iAccounts, sum(Balance) as Balance, cUserID from curTremp group by cUserID
>
>or
>
>select count(cTrans_pk) as iAccounts, sum(Balance) as Balance, cUserID from ... where ... group by cUserID
>
>E.g. do it in two steps or in 1 step?

if you uses curTemp only once the second it is better
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform