I have a mysql database with +25K rows including geometry and other attributes. Using a mysql2geojson php script I then added it to a leaflet map.

It is super slow now, what can I do to boost the performance?

I'm using www.one.com as host meaning I dont have access to anything else than php/mysql. I can't get postgis/geoserver, etc.

I also intend to design a search filter limiting which points to be shown on the map. For this purpose, is it best to do new calls to the database, or should I be working against a "local dump" for the searching?

To summarize I wonder how to best work with big point data sets with mysql/php/leaflet including searching. Any tips are welcome!

  • Anders, are you loading all your data at once from a single request upon initialization, or are you requesting fresh data every time the map is zoomed/panned for only that data which would be visible in the map's bounding area?
    – elrobis
    Oct 1, 2014 at 15:37

3 Answers 3


Here are a couple of thoughts on what you can do to boost performance:

  1. Send a BBox to server and return only points within it
  2. Use a library like turf.js http://turfjs.org/ on the client to only draw points within the maps current BBox
  3. Marker Clustering https://github.com/Leaflet/Leaflet.markercluster
  4. Use SVG icons instead of images
  5. Only return geometry and unique identifier of points, than send a query to the server to get the details for that point. This will decrease the initial load of your json file and memory stored on the client.
  6. Use web workers to download the json while running other functions

Ideally you would generate tiles for this large of a load, but the previous pointers should help guide to better performance.


You might try a clustering strategy such as the Leaflet Marker Clustering plugin - https://github.com/Leaflet/Leaflet.markercluster

You can see an example of this at work here - http://leaflet.github.io/Leaflet.markercluster/example/marker-clustering-realworld.388.html

Another strategy (although maybe not feasible given your constraints) would be to create map tiles using something like TileMill with UTFGrids for mouse events / discoverability.


maybe we can use mysql index to load 1000 rows each at a time..Logically its almost same as map tiling

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.