It looks like you are using geolocation data. If the database backend is Postgres, check to see if you have or can install PostGIS extensions. This gives you very quick tools that give you searches such as “searching for the closest thing to this point”, “searching for everything inside this circle”, “searching for everything within this square”, etc.
http://postgis.refractions.net/
You would do something like this:
CREATE INDEX [indexname] ON [tablename] USING GIST ( [geometrycolumn] gist_geometry_ops);
Then you can do something like this - find everything within 100 meters of the point:
SELECT * FROM GEOTABLE WHERE GEOM && GeometryFromText('BOX3D(900 900,1100 1100)',-1) AND Distance(GeometryFromText('POINT(1000 1000)',-1),GEOM) < 100;
Examples from the manual .
source share