Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Questions
Message
From
23/09/2005 20:12:26
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
01052562
Message ID:
01052632
Views:
9
>>So...are JOINS generally faster than using the subset version?
>>
>>I was just going to ask if the following would be better implemented with JOINS.
>>
>>
>>SELECT * FROM crsMatchResults ;
>>INTO CURSOR crsMatchResults ;
>>WHERE ;
>>(Sequence in (SELECT Sequence FROM crsSurvivors) OR ;
>> Sequence in (SELECT Sequence FROM crsDuplicates)) AND ;
>>(GroupNum in (SELECT GroupNum FROM crsSurvivors) AND ;
>> GroupNum in (SELECT GroupNum FROM crsDuplicates)) ;
>>ORDER BY Sequence ;
>>READWRITE NOFILTER
>>
>>
>
>James,
>
>There's no simple answer. Often JOINs are faster but only tests can give the answer in each particular case.
>SELECT * FROM crsMatchResults ;
>	INTO CURSOR crsMatchResults ;
>	WHERE ;
>		Sequence in ( ;
>			SELECT Sequence FROM crsSurvivors  ;
>			UNION ALL SELECT Sequence FROM crsDuplicates) AND ;
>		GroupNum in ( ;
>			SELECT GroupNum FROM crsSurvivors ;
>			UNION ALL SELECT GroupNum FROM crsDuplicates) ;
>	ORDER BY Sequence ;
>	READWRITE NOFILTER
>	>	>SELECT * FROM crsMatchResults mr ;
>	INTO CURSOR crsMatchResults ;
>	JOIN ( ;
>			SELECT Sequence FROM crsSurvivors  ;
>			UNION ALL SELECT Sequence FROM crsDuplicates) dt1 ;
>		ON dt1.Sequence = mr.Sequence  ;	
>	JOIN ( ;
>			SELECT GroupNum FROM crsSurvivors ;
>			UNION ALL SELECT GroupNum FROM crsDuplicates) dt2 ;
>		ON dt2.GroupNum = mr.GroupNum ;	
>	ORDER BY Sequence ;
>	READWRITE NOFILTER
>	>
Thanks for the advice Sergey. I know that test are the only real way to determine, but the project I'm working on right now has so many of these SELECT statements for a single process that I was just looking for a "default" way (if you will) to formulate these queries.

If JOINS are generally faster I'll use JOINS and only go testing different SELECT structures when something doesn't seem up to par.

Aloha,

James
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform