What to Partition By for maximum performance in distance computation (lat/long)
This isn't a question more for asking some guidance.
I am creating a DataFrame by using spark.sql and ST_Point like this:
...
// here _c0 and _c1 are lat and long
val points = spark.sql("SELECT ST_Point(CAST(_c0 AS Decimal(24,20)), CAST(_c1 AS Decimal(24,20))) as pt FROM raw")
...
Then I compute a distance between rows in "points" using ST_Distance but I found that there is no performance gain even if I add more executors. So I am guessing points dataframe needs to have a partition. In this case what would be an ideal partition field?
@keeyong ST_Distance between columns is cross join. There is no way to optimize it. It has O(n^2) complexity
I see @jiayuasu. Is there a way to avoid this?
Add a predicate such as
select ST_Distance( A, B) From df Where ST_Distance(A,B) <= 10
This will trigger GeoSpark optimized inner join. But you need to make sure in your case, you don’t need the full cross join results.
There is no way to optimize a cross join.
On Sat, Aug 11, 2018 at 10:25 keeyong [email protected] wrote:
I see @jiayuasu https://github.com/jiayuasu. Is there a way to avoid this?
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/DataSystemsLab/GeoSpark/issues/259#issuecomment-412289866, or mute the thread https://github.com/notifications/unsubscribe-auth/AKcRAGbkly5vnlLAbXBt_ElaDpxB0gqdks5uPxOjgaJpZM4V4hUe .
--
Jia Yu,
Ph.D. Student in Computer Science
Arizona State University http://www.asu.edu/
Reach me via Jia Yu's Homepage http://www.public.asu.edu/~jiayu2/ | GitHub Repositories https://github.com/jiayuasu
Follow GeoSpark on Website http://datasystemslab.github.io/GeoSpark/ | GitHub https://github.com/DataSystemsLab/GeoSpark | Twitter https://twitter.com/GeoSpark_ASU
Thanks!