title: spark access first n rows - take vs limit
body: <p>I want to access the first 100 rows of a spark data frame and write the result back to a CSV file.</p>
  <p>Why is <code>take(100)</code> basically instant, whereas</p>
  <pre><code>df.limit(100)
        .repartition(1)
        .write
        .mode(SaveMode.Overwrite)
        .option(&quot;header&quot;, true)
        .option(&quot;delimiter&quot;, &quot;;&quot;)
        .csv(&quot;myPath&quot;)
  </code></pre>
  <p>takes forever.
  I do not want to obtain the first 100 records per partition but just any 100 records.</p>
  <p>Why is <code>take()</code> so much faster than <code>limit()</code>?</p>