Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Select Optimisation changes under VFP8?
Message
De
03/06/2003 11:54:21
Cindy Winegarden
Duke University Medical Center
Durham, Caroline du Nord, États-Unis
 
 
À
03/06/2003 10:51:06
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00795674
Message ID:
00795726
Vues:
23
>I have encountered some behaviour in VFP8 that seems like an optimisation setting has changed.
>
>When issuing a query like:
>
>
>SELECT * FROM table WHERE (field = 'abc' and SomeFunction(field))
>
>
>In the past, this query would test field='abc', and if not, not carry out the second test SomeFunction(field). This behaviour allows select commands to be optimised - check the quick things before checking the slow things.
>
>However, in VFP 8 every single expression in an SQL command appears to be evaluated. In the above example the SomeFunction(field) test is always carried out, regardless of whether field = 'abc'.
>
>Can anyone confirm that this is the case, and if so is there a setting that will return behaviour to the VFP7 standard. I have looked at SET OPTIMIZE and SET ENGINEBEHAVIOUR, and neither seems to affect the query.

Hi Dominic,

The following code behaves exactly the same way under VFP 6-8. It evaluates the function for every record.
CREATE CURSOR Test (Field1 N(10))
FOR lnCount = 1 TO 20
	INSERT INTO Test VALUES (lnCount)
ENDFOR

SELECT * FROM Test ;
	WHERE Field1 >= 10 AND IsEven(Field1)

FUNCTION IsEven(tnNumber)
	? "Number is: " + TRANSFORM(tnNumber)
	RETURN (MOD(tnNumber, 2) = 0)
ENDFUNC
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform