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

Can you Speed up this query

Status
Not open for further replies.

jkelly2956

Programmer
Jul 31, 2002
37
US
Can anyone give me any suggestions on speeding this query up. I have indexes on the lat and longs in both tables. Basically I have a list of places in W_Data....and a list of alternate names for those places in ULocator. I want to do a search for all places where a name contains 'al' and if the original name or one of its alternates is a hit.. I want to show the original name and lat and long.


Code:
SELECT wd.pName,wd.DD_Lat,wd.DD_Long
FROM W_Data wd
LEFT JOIN ULocator ul ON ( 69.09 * DEGREES( ACOS( SIN( RADIANS( ul.Latitude ) ) * SIN( RADIANS( wd.DD_Lat ) ) + COS( RADIANS( ul.Latitude ) ) * COS( RADIANS( wd.DD_Lat ) ) * COS( RADIANS( ul.Longitude - wd.DD_Long ) ) ) ) ) < .1
WHERE ul.pName
LIKE '%al%' OR wd.pName
LIKE '%al%'
 
I can't see how you could speed this query up. Your indexes are no use, as the use of functions and LIKE expressions with leading %'s ensures they won't be used.

-----
ALTER world DROP injustice, ADD peace;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top