Cheng Lian created SPARK-17972:

             Summary: Query planning slows down dramatically for large query 
plans even when sub-trees are cached
                 Key: SPARK-17972
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 2.0.1, 1.6.2
            Reporter: Cheng Lian
            Assignee: Cheng Lian

The following Spark shell snippet creates a series of query plans that grow 
exponentially. The {{i}}-th plan is created using 4 *cached* copies of the {{i 
- 1}}-th plan.

(0 until 6).foldLeft(Seq(1, 2, 3).toDS) { (plan, iteration) =>
  val start = System.currentTimeMillis()
  val result = plan.join(plan, "value").join(plan, "value").join(plan, 
"value").join(plan, "value")
  System.out.println(s"Iteration $iteration takes time 
${System.currentTimeMillis() - start} ms")[Int]

We can see that although all plans are cached, the query planning time still 
grows exponentially and quickly becomes unbearable.

Iteration 0 takes time 9 ms
Iteration 1 takes time 19 ms
Iteration 2 takes time 61 ms
Iteration 3 takes time 219 ms
Iteration 4 takes time 830 ms
Iteration 5 takes time 4080 ms

Similar scenarios can be found in iterative ML code and significantly affects 

This message was sent by Atlassian JIRA

To unsubscribe, e-mail:
For additional commands, e-mail:

Reply via email to