cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
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_Fatma
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.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group