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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

looking for ideas to speed up SQL

Status
Not open for further replies.

pauljt

Technical User
Feb 26, 2003
31
GB
Have a piece of SQL:

select INSTNUM,'',IDXCOD,INSTFREE,INSTFREE2,YLD
from HIST h where DAT =
(select max(DAT) from HIST h2 where h.INSTNUM = h2.INSTNUM)
go

which runs fine, albeit a bit slow.


An unique clustered index exists for
INSTNUM, DAT

The subquery uses this, the outer query does not.


Just looking for ideas! to speed it up if possible.
 
sometimes you can do some query to use the index if you put it in orderby.

Ion Filipski
1c.bmp
 
Depends on the database but maybe an index on DAT would be used for the outer query.



======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top