Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why is this SQL faster?
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00930072
Message ID:
00930076
Vues:
13
Mel,
The best way in this case would be to use macro substitution. This way JOIN will be optimizable with proper indexes.
IF cIsGrouped
	cJoin1 = [ Ssperson.familyid = Ssmoney.familyid ]
ELSE 
	cJoin1 = [ sperson.personid = Ssmoney.personid ]
ENDIF	
INNER JOIN appdata!Ssmoney ;
	ON &cJoin1
>Can someone tell me why this SQL line:
>
>INNER JOIN appdata!Ssmoney ;
>ON IIF(cIsGrouped=.F.,Ssperson.personid,Ssperson.familyid) =
>   IIF(cIsGrouped=.F.,Ssmoney.personid,Ssmoney.familyid)
>
>takes a second to process and the following one:
>
>INNER JOIN appdata!Ssmoney ;
>ON  IIF(cIsGrouped=.F.,Ssperson.personid = Ssmoney.personid,
>    Ssperson.familyid = Ssmoney.familyid)
>
>takes several minutes?
>
>Note: the ON IIF() lines are actually one line in my actual code, I just put it in 2 lines for this posting.
>
>I am just trying to get a handle on how to write the best SQL code.
>
>Logic would tell me there is no difference, but obviousely there is.
>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform