I continued searching and I found an alternative to KMeans: GEOHASH
Wikipedia will better explain to me what it is: Wiki geohash
But to summarize. The world map is divided into a grid of 32 cells and each is assigned an alphanumeric character. Each cell is also divided into 32 cells and so on into 12 levels. Therefore, if I do GROUP BY in the first letter of the hash, I will get my clusters for the lowest level of scaling, if I need higher precision, I just need to group the first N letters of my hash.
So, what I did is add only one field to my table and generate a hash corresponding to my coordinates:
ID | latitude | longitude | geohash | other_sutff 1 | 50.4371243 | 5.9681102 | csyqm73ymkh2 | ... 2 | 50.3305477 | 6.9420498 | p24k1mmh98eu | ... 3 | -33.4510148 | 149.5519662 | 8x2s9674nd57 | ...
Now, if I want to get my clusters, I just need to make a simple request:
SELECT count(*) as nb_markers FROM mtable GROUP BY SUBSTRING(geohash,1,2);
In substring 2 is the level of accuracy and should be between 1 and 12
PS: Lib I used to generate my hash
source share