Link to home
Start Free TrialLog in
Avatar of Ricky White
Ricky WhiteFlag for United States of America

asked on

Optimize this Sql query?

We are usng Sql Server 2000.
I have 2 tables A and B each having about 100,000 records in it.

I am running the following query but it takes a minute or so to run and as a result the user has to wait for the data table to be populated on the screen everytime an account has to be searched.

Is there a way to optimize this query to reduce the response time?
*******************************************
SELECT A.col1, A.col2, A.col3, B.col4
FROM A inner JOIN B ON A.AccountNumber = B.AccountNumber
where A.col1 = 'something' or A.col2 = 'something' or A.col3 = 'something'

******************************************

As you can see, Table B is used only in select and not in where.

Thanks!
SOLUTION
Avatar of sventhan
sventhan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sean Stuber
Sean Stuber

is accountnumber unique in B ?

will every row in A have a row in B or is the inner join acting as a filter?
Avatar of Ricky White

ASKER

Yes every row in A will have a row in B.

The account number in B is not unique.

Thanks.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks all!
Sorry, I meant to mark DWKor's answer as the best answer.