Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why is this SQL faster?
Message
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00930072
Message ID:
00930076
Views:
12
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--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform