Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query for optimization

Status
Not open for further replies.

leo6

Programmer
Mar 2, 2005
22
US
Could this query run better ?

select a.col1 , a.col2
from tab1 a, tab2 b
where a.col3=b.col3
and a.col4 = <constant>

a.col3=b.col3 is required because we need the output when a.col3 has a matching value for b.col3

 
There are a couple of other ways that you could write this query. However they won't improve performance any.
Code:
select a.col1 , a.col2 
from tab1 a, 
join tab2 b on a.col3=b.col3 
where a.col4 = <constant>
or
Code:
select a.col1 , a.col2 
from tab1 a
where a.col3 in (select col3 from tab2)
and a.col4 = <constant>


Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)

[noevil]
(My very old site)
 
I was looking for performance improvement on this...
Is it possible ???

select a.col1 , a.col2
from tab1 a, tab2 b
where a.col3=b.col3
and a.col4 = <constant>
 
Have you checked the Estimated Execution Plan for this query? If not, open it in QA and do so. You might also want to run a Trace on it while executing the query so you can run the Index Tuning Wizard which might help you improve performance.



Catadmin - MCDBA, MCSA
Beware the error of pre-emptive poultry inventory!
 
Beware the error of pre-emptive poultry inventory!
is
Don't count your chickens before they hatch??????

---------------------------------------
The customer may not always be right, but the customer is ALWAYS the customer.
 
Yep. You wouldn't believe how many people at my workplace can't figure that one out. @=)



Catadmin - MCDBA, MCSA
Beware the error of pre-emptive poultry inventory!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top