cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

Cosine similarity between all rows pairwise on a dataset of 100million rows

Databricks2005
New Contributor II

Hello everyone,

I am facing performance issue while calculating cosine similarity in pyspark on a dataframe with around 100 million records.

I am trying to do a cross self join on the dataframe to calculate it.​

The executors are all having same number of tasks when seen on the spark ui.

The input size to all executors is also almost the same.

Executors : 20

Cores: 4 cores ​

Any inputs would be highly appreciated​

1 ACCEPTED SOLUTION

Accepted Solutions

john_odwyer
New Contributor III

The issue is probably related to the self join between 100 million rows, I'm not positive without seeing the code and understanding the problem better but you may want to think about using windowing functions instead

https://blog.knoldus.com/using-windows-in-spark-to-avoid-joins/

View solution in original post

4 REPLIES 4

Kaniz
Community Manager
Community Manager

Hi @ Databricks2005! My name is Kaniz, and I'm the technical moderator here. Great to meet you, and thanks for your question! Let's see if your peers on the community have an answer to your question first. Or else I will follow up with my team and get back to you soon.Thanks.

Thank you Kaniz !. I shall wait for an answer 🙂

john_odwyer
New Contributor III

The issue is probably related to the self join between 100 million rows, I'm not positive without seeing the code and understanding the problem better but you may want to think about using windowing functions instead

https://blog.knoldus.com/using-windows-in-spark-to-avoid-joins/

Sonal
New Contributor II

Is there a way to hash the record attributes so that the cartesian join can be avoided? I work on record similarity and fuzzy matching and we do a learning based blocking alorithm which hashes the records into smaller buckets and then the hashes are joined. You can check https://github.com/zinggAI/zingg for the approach.