Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can this SQL be tweaked???
Message
From
15/05/2002 18:09:15
 
 
To
14/05/2002 20:59:19
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00656628
Message ID:
00657184
Views:
24
After looking at your code you can optimize it in a way you may not have anticipated:

Rather than use "HAVING" to filter the query, use an "AND" expression like this:


Select ... blah blah blah ...
Where ... blah blah ...
And myField = SomeValue

Rather than
Select ... blah blah blah ...
Where ... blah blah ...
Having myField = SomeValue

Doing this instead of using the "HAVING" expression will save your query this way:

The HAVING part of the query is applied to the final result set of the query. It does not limit the data being queried. It's particularly usefull for finding data in aggregation queries. Like: give me the salesmen who's total sales is greater than 1 million dollars. To find this you must sum up the sales of all the salesmen then you can find the result.

But if you put the query in the AND expression, it limits the number of records included in the result set, so the query has fewer records to process, which speeds things up. You'll get even more improvement if you can make the AND expressions RUSHMORE optimizable.

HTH
Previous
Reply
Map
View

Click here to load this message in the networking platform