Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sub queries or separate SELECTs?
Message
 
À
23/09/2005 19:07:09
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01052615
Message ID:
01052620
Vues:
7
>Hi,
>
>Is there a speed advantage to using separate SELECT commands as opposed to humping them up into a single command using sub queries?
>
>Here's an example of what I'm refering to:
>
>SELECT Field1,CNT(*) as nTotal FROM ATable INTO CURSOR crsCursor1 GROUP BY Field1
>
>SELECT nTotal FROM crsCursor1 INTO CURSOR crsCursor2
>
>
>as opposed to
>
>
>SELECT nTotal FROM (SELECT Field1,CNT(*) as nTotal FROM ATable GROUP BY Field1) INTO CURSOR crsCursor2
>
>
>The first example is more of a pain to clean up after but is easier to debug. I'm just wondering if there is a runtime speed advantage to any of them.
>
>Aloha,
>
James,

It depends on what you want. Is it an INNER JOIN or OUTER? What I see and suspect you want is an INNER

In either case, the latter will perform better if an index tag exists on field1. The result set of the sub-query will use it. If it doesn't, then the latter will probably perform better.
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform