Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
View Macro Substitution in a SQL statement
Message
From
29/09/1997 16:21:05
 
 
To
29/09/1997 16:12:22
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00052240
Message ID:
00052271
Views:
44
>>>Using macro substitution inside a query is a bad idea anyway because it forces SQL to evaluate the macro for every row, and slows the query dramatically. HTH
>>
>>Erik, are you sure about this? If yes, then try some quick test.
>>Actually, this is UDF which might be evaluated for each row.
>
>No, I am not sure, Ed, it's just what I have always been told. (This was also discussed in one of the DevCon sessions... I'll have to look at my notes to remember which one.)
>
>I did one quick test though...
>
>lfilter = "lname = 'Moore'"
>before1 = seconds()
>select * from campus into cursor cursor1 where &lfilter
>after1 = seconds()
>elapsed1 = after1 - before1
>wait window "Query1: " + str(elapsed1)
>
>Wait window returned "Query1: 23"
>
>I then exited VFP, returned and changed the code to:
>
>before2 = seconds()
>lquery = 'Select * from campus into cursor cursor2 where lname = "Moore"'
>&lquery
>after2 = seconds()
>elapsed2 = after2 - before2
>wait window "Query2: " + str(elapsed2)
>
>Wait window returned "Query1: 11"
>
>I realize this isn't the most dependable of tests, but nothing better came immediately to mind. Have you tested for the performance difference? I am interested to hear the results.

As I understand Foxpro will first evaluate macros, compile whole command and run query, so macro will be evaluated once. My tests don't show time difference. I will appreciate replies from other UT members on this topic.
Edward Pikman
Independent Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform