Ricky White
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!
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes every row in A will have a row in B.
The account number in B is not unique.
Thanks.
The account number in B is not unique.
Thanks.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks all!
ASKER
Sorry, I meant to mark DWKor's answer as the best answer.
will every row in A have a row in B or is the inner join acting as a filter?