Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
3.67/5 (2 votes)
See more:
Actually i my functionality is if i pass ZIP code as a parameter to stored proc i should get the users under 50 kilometers radius. is it possible...and i had query but it is not executing fastly so it is giving time out exception
Posted
Comments
Keith Barrow 26-Jul-13 8:06am    
It'd be worth updating your question (use the green "Improve question" link to describe what it is the current query does (or post the query if it is not too long).

One thing to *try* to improve performance that sprung to mind immediately was to maintain latitude and longitude fields against zip codes. You can then calculate maximum & minimum longitudes and latitudes for the original codes (i.e. to form a "square"), then query ZIP codes in that square into a temp table. This is less computationally expensive than getting all ZIP code's distances from the start point, then deciding if < 50km. You can then run the query you have on the square results temp table (to get those in the radius) on a much smaller subset of ZIP codes.

I'm not sure how ZIP codes are organised (we have our own system in the UK) but there might be systematic things you can do to filter out candidates for example getting ZIP codes that border first, and traversing "borderers of borderers" until you get no results.

The other thing that I don't know if you need to handle is that ZIP codes aren't points (in the UK Post Codes represent streets, more or less) so I don't know whether you need to take into account the physical area of the code.
RedDk 26-Jul-13 11:52am    
see "SELECT" and geospatial data types "geography" and "geometry". Look it up in BOL

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900