I am doing a tracking query. The device is sending its location data, timestamp to store in MySQL Database. I want to show the query result of every point with its nearest POI. The POI database is stored in PostgreSQL database as PostGIS format. Its taking 8-9 seconds to return the query result. At first I am calling the longitude latitude values from MySQL Database then calling the nearest POI info for every point from PostgreSQL database using while loop. I want to know is there any way to reduce the query time? I am using the following query
SELECT name, area, district, ST_Distance(geom::geography,ST_GeographyFromText('POINT( $longitude $latitude )')) as distance FROM poi ORDER BY distance Limit 1;
I need to get a JSON result to visualize on map.