1.Circle range query
SELECT COUNT(*) FROM table_name WHERE
ST_Intersects(ST_Buffer(ST_Point(x1,y1), radius), ST_Point(x, y));
2. BBOX range query
SELECT COUNT(*) FROM table_name WHERE
ST_Contains(ST_GeomFromText('POLYGON ((x1 y1, x2 y2, .. , x1 y1))'), ST_Point(x, y));
3. k-NN query (k=10)
SELECT ST_Distance(ST_Point(x1, y1), ST_Point(x, y)) as distance, x, y FROM
table_name ORDER BY distance ASC LIMIT 10;
Kindly let me know the optimized way to implement the above queries (especially k-NN).
Thanks & Regards
Vigneswaran