Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Both work, which is best
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00782049
Message ID:
00782055
Views:
10
Hi Sarah,

In my expirience the second quiery is faster in most cases. However, as with all queries, only test on real or close to real data can give you the answer.

>I have a query I'd like to optimise.
>
>I don't have a huge amount of test data but it appears that when the rows returned increases that option 2 is the most efficient. Is that consistent with others?
>
>Table 1 has a 1:M relationship with Table 2. The id's are indexed.
>** The Code:
>lcTest = "Rent"
>*lcTest = "Accounting"
>*lcTest = "Bank Charges"
>
>lnseconds = seconds()
>
>select distinct table1.* ;
>  from table1, table2;
>  where table1.table1id  = entrydet.table1id;
>  and table2.category = lcTest;
>  into cursor q1
>
>? seconds() - lnseconds
>
>lnseconds = seconds()
>select * from table1;
>  where table1id in (select table1id from table2 where category = lcTest);
>  into cursor q2
>
>? seconds() - lnseconds
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform