Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Quickest Way To Execute A Query You Know Will Have No Re
Message
 
 
To
16/09/2004 11:37:12
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00942957
Message ID:
00942987
Views:
17
This message has been marked as the solution to the initial question of the thread.
Gary,

There's no overhead in quering table with 'WHERE 1=2' because SQL Server can optimize it. There's also SQL Server specific approach as shown in Re: How to return an empty result Message #810500.

>
>I have a number of SQL server tables that are related to a parent table. The parent table has bit columns that indicate whether there is any related data in each of the child tables. On the client side, when the parent record is changed, I want to requery the child tables where I know data exists but effectively empty the child cursor(s) where I know there is no data on the SQL server. Obviously, requerying these "known" empty child tables with the apropriate parameter will result in no records being returned. However, SQL server will have to go through the process (and overhead) of querying the table(s) in question simply to find out what we knew ahead of time - there are no records.
>
>I am using SQL passthru and my framework makes provision for a dynamic WHERE clause. So, when I know there are no child records (because the parent record bit flag tells me so), I could assign a new WHERE clause of "WHERE 1 = 2". This will return an empty result set and ensure that all bound controls are "empty" and "dimmed" as they should be where their data source is empty.
>
>The question is, what kind of overhead reduction (if any) am I likely to get by asking the query to find records "WHERE 1 = 2" rather than looking through the table for records that match the view parameter value when I alread know ahead of the query that they don't exist?
>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform