title: How to achieve Rownum feature in Spark Dataframe similar to oracle rownum
body: <p>I am new to spark and I am trying to create a rownumer for large dataset.
  I tried using row_number window function, which works fine but its not performance efficient as I am not using partitionBy clause.</p>
  
  <p>Eg:  </p>
  
  <pre><code> val df= Seq(
          ("041", false),
          ("042", false),
          ("043", false)
        ).toDF("id", "flag")
  </code></pre>
  
  <p>Result should be :</p>
  
  <pre><code>val df= Seq(
          ("041", false,1),
          ("042", false,2),
          ("043", false,3)
        ).toDF("id", "flag","rownum")
  </code></pre>
  
  <p>currently I am using                       </p>
  
  <pre><code>df.withColumn("rownum",row_number().over(Window.orderBy($"id")))
  </code></pre>
  
  <p><strong>Is there any other way to achieve this result without using window functions?
  I also tried monotonicallyIncresingID and ZipwithIndex</strong></p>