Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to optimize the SQL select
Message
From
17/10/2006 14:44:06
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
How to optimize the SQL select
Miscellaneous
Thread ID:
01162669
Message ID:
01162669
Views:
57
Hi all,

I have 2 SQL select below, the 1st one ran for more than 2 hours and I have
to stop by doing CTRL ALT-DEL to stop without any results

The second one run for 5 minutes , I got the results.

How much is the difference between the 2 SQL select below,
please guide me how to optimize the 1st one if it is possible

It is about 30000 records for both [qry - VarCreditMarge_BE] and [qry - VarJunMarge_MatchAccount_BE] queries inside the select itself.

TIA
**1st:

SELECT DISTINCT [qry - VarCreditMarge_BE].*
FROM [qry - VarCreditMarge_BE]
WHERE [qry - VarCreditMarge_BE].vcnumca2 in
  (select  [qry - VarJunMarge_MatchAccount_BE].vcnumca2  from [qry - VarJunMarge_MatchAccount_BE]
                where  [qry - VarJunMarge_MatchAccount_BE].MatchAccount=0)


**second:

SELECT DISTINCT [qry - VarCreditMarge_BE].*, [qry - VarJunMarge_MatchAccount_BE].[MatchAccount]
FROM [qry - VarCreditMarge_BE] INNER JOIN [qry - VarJunMarge_MatchAccount_BE] ON [qry - VarCreditMarge_BE].[vcnumca2]=[qry - VarJunMarge_MatchAccount_BE].[vcnumca2]
WHERE [qry - VarJunMarge_MatchAccount_BE].[MatchAccount]=0
Next
Reply
Map
View

Click here to load this message in the networking platform