Does Postgis ST_FrechetDistance have limitations?

Viewed 56

Using ST_FrechetDistance(geom1, geom2) from Postgis will cause my Postgres server to lose connection if the number of points in the geometries is in the thousands(+6k). Is it possible to increase this limitation or bypass it somehow? It works perfectly fine with smaller geometries.

1 Answers

This is an O(n**2) operation. So working with 1000 points will take roughly four times as long as working with 500 points, and 100 times as long as working with 100 points. O(n**2) is a harsh master.

Try setting the densityFrac parameter to break up your long geometries. It's the third parameter to the function. In this example it dedensifies -- breaks up -- your segments into tenths.

ST_FrechetDistance(geo1::geometry, geo2::geometry, 0.1);
Related