title: Apache Spark-SQL vs Sqoop benchmarking while transferring data from RDBMS to hdfs
body: <p>I am working on a use case where I have to transfer data from RDBMS to HDFS. We have done the benchmarking of this case using sqoop and found out that we are able to transfer around 20GB data in 6-7 Mins. </p>
  
  <p>Where as when I try the same with Spark SQL, the performance is very low(1 Gb of records is taking 4 min to transfer from netezza to hdfs). I am trying to do some tuning and increase its performance but its unlikely to tune it to the level of sqoop(around 3 Gb of data in 1 Min).</p>
  
  <p>I agree to the fact that spark is primarily a processing engine but my main question is that both spark and sqoop are using JDBC driver internally so why there is so much difference in the performance(or may be I am missing something). I am posting my code here.</p>
  
  <pre><code>object helloWorld {
    def main(args: Array[String]): Unit = {
      val conf = new SparkConf().setAppName("Netezza_Connection").setMaster("local")
      val sc= new SparkContext(conf)
      val sqlContext = new org.apache.spark.sql.hive.HiveContext(sc)
      sqlContext.read.format("jdbc").option("url","jdbc:netezza://hostname:port/dbname").option("dbtable","POC_TEST").option("user","user").option("password","password").option("driver","org.netezza.Driver").option("numPartitions","14").option("lowerBound","0").option("upperBound","13").option("partitionColumn", "id").option("fetchSize","100000").load().registerTempTable("POC")
      val df2 =sqlContext.sql("select * from POC")
      val partitioner= new org.apache.spark.HashPartitioner(14)
      val rdd=df2.rdd.map(x=&gt;(String.valueOf(x.get(1)),x)).partitionBy(partitioner).values
      rdd.saveAsTextFile("hdfs://Hostname/test")
    }
  }
  </code></pre>
  
  <p>I have checked many other post but could not get a clear answer for the internal working and tuning of sqoop nor I got sqoop vs spark sql benchmarking .Kindly help in understanding this issue.</p>