1,270
社区成员




System.out.println("0>>>>>>>>>>>>>>>" + Util.toStr(null));
Dataset<Row> jdbcDF = spark.read().format("jdbc")
.option("url", "jdbc:oracle:thin:@192.168.56.1:1521:orcl")
.option("dbtable", "testTable")
.option("user", "test")
.option("password", "test")
.option("driver", "oracle.jdbc.driver.OracleDriver")
.load();
jdbcDF.select("testcol", "testcol1").orderBy("testcol").write().parquet("hdfs://master:9000/test.parquet");
System.out.println("1>>>>>>>>>>>>>>>" + Util.toStr(null));
Dataset<Row> parquetFileDF = spark.read().parquet("hdfs://master:9000/test.parquet");
System.out.println("2>>>>>>>>>>>>>>>" + Util.toStr(null));
parquetFileDF.createOrReplaceTempView("parquetFile");
String sql = "SELECT testcol,count(*) c FROM parquetFile group by testcol order by c desc";
System.out.println("sql:"+ sql);
Dataset<Row> namesDF = spark.sql(sql);
System.out.println("3>>>>>>>>>>>>>>>" + Util.toStr(null));
System.out.println("4>>>>>>>>>>>>>>>" + Util.toStr(null));
namesDF.show();
System.out.println("5>>>>>>>>>>>>>>>" + Util.toStr(null));
结果发现,把parquet读出到运算得出结果大约7秒左右,比oracle运行速度稍慢一点点。
我的spark用的是三台linux虚拟机,一台master,两台worker。
请问有没有更好的方法,进一步提高效率?秒级的响应速度 。我用的测试数据是百万级别。[/quote]
首先group by count不要作为性能评估依据。。。其次你用SparkSQL就是要用UDF/UDAF以及要跑很久的复杂查询,否则你直接JDBC查Oracle算了。。。最后3台虚拟机。。。给个眼神你自己体会 System.out.println("0>>>>>>>>>>>>>>>" + Util.toStr(null));
Dataset<Row> jdbcDF = spark.read().format("jdbc")
.option("url", "jdbc:oracle:thin:@192.168.56.1:1521:orcl")
.option("dbtable", "testTable")
.option("user", "test")
.option("password", "test")
.option("driver", "oracle.jdbc.driver.OracleDriver")
.load();
jdbcDF.select("testcol", "testcol1").orderBy("testcol").write().parquet("hdfs://master:9000/test.parquet");
System.out.println("1>>>>>>>>>>>>>>>" + Util.toStr(null));
Dataset<Row> parquetFileDF = spark.read().parquet("hdfs://master:9000/test.parquet");
System.out.println("2>>>>>>>>>>>>>>>" + Util.toStr(null));
parquetFileDF.createOrReplaceTempView("parquetFile");
String sql = "SELECT testcol,count(*) c FROM parquetFile group by testcol order by c desc";
System.out.println("sql:"+ sql);
Dataset<Row> namesDF = spark.sql(sql);
System.out.println("3>>>>>>>>>>>>>>>" + Util.toStr(null));
System.out.println("4>>>>>>>>>>>>>>>" + Util.toStr(null));
namesDF.show();
System.out.println("5>>>>>>>>>>>>>>>" + Util.toStr(null));
结果发现,把parquet读出到运算得出结果大约7秒左右,比oracle运行速度稍慢一点点。
我的spark用的是三台linux虚拟机,一台master,两台worker。
请问有没有更好的方法,进一步提高效率?秒级的响应速度 。我用的测试数据是百万级别。[/quote]
首先group by count不要作为性能评估依据。。。其次你用SparkSQL就是要用UDF/UDAF以及要跑很久的复杂查询,否则你直接JDBC查Oracle算了。。。最后3台虚拟机。。。给个眼神你自己体会 System.out.println("0>>>>>>>>>>>>>>>" + Util.toStr(null));
Dataset<Row> jdbcDF = spark.read().format("jdbc")
.option("url", "jdbc:oracle:thin:@192.168.56.1:1521:orcl")
.option("dbtable", "testTable")
.option("user", "test")
.option("password", "test")
.option("driver", "oracle.jdbc.driver.OracleDriver")
.load();
jdbcDF.select("testcol", "testcol1").orderBy("testcol").write().parquet("hdfs://master:9000/test.parquet");
System.out.println("1>>>>>>>>>>>>>>>" + Util.toStr(null));
Dataset<Row> parquetFileDF = spark.read().parquet("hdfs://master:9000/test.parquet");
System.out.println("2>>>>>>>>>>>>>>>" + Util.toStr(null));
parquetFileDF.createOrReplaceTempView("parquetFile");
String sql = "SELECT testcol,count(*) c FROM parquetFile group by testcol order by c desc";
System.out.println("sql:"+ sql);
Dataset<Row> namesDF = spark.sql(sql);
System.out.println("3>>>>>>>>>>>>>>>" + Util.toStr(null));
System.out.println("4>>>>>>>>>>>>>>>" + Util.toStr(null));
namesDF.show();
System.out.println("5>>>>>>>>>>>>>>>" + Util.toStr(null));
结果发现,把parquet读出到运算得出结果大约7秒左右,比oracle运行速度稍慢一点点。
我的spark用的是三台linux虚拟机,一台master,两台worker。
请问有没有更好的方法,进一步提高效率?秒级的响应速度 。我用的测试数据是百万级别。[/quote]
首先group by count不要作为性能评估依据。。。其次你用SparkSQL就是要用UDF/UDAF以及要跑很久的复杂查询,否则你直接JDBC查Oracle算了。。。最后3台虚拟机。。。给个眼神你自己体会 System.out.println("0>>>>>>>>>>>>>>>" + Util.toStr(null));
Dataset<Row> jdbcDF = spark.read().format("jdbc")
.option("url", "jdbc:oracle:thin:@192.168.56.1:1521:orcl")
.option("dbtable", "testTable")
.option("user", "test")
.option("password", "test")
.option("driver", "oracle.jdbc.driver.OracleDriver")
.load();
jdbcDF.select("testcol", "testcol1").orderBy("testcol").write().parquet("hdfs://master:9000/test.parquet");
System.out.println("1>>>>>>>>>>>>>>>" + Util.toStr(null));
Dataset<Row> parquetFileDF = spark.read().parquet("hdfs://master:9000/test.parquet");
System.out.println("2>>>>>>>>>>>>>>>" + Util.toStr(null));
parquetFileDF.createOrReplaceTempView("parquetFile");
String sql = "SELECT testcol,count(*) c FROM parquetFile group by testcol order by c desc";
System.out.println("sql:"+ sql);
Dataset<Row> namesDF = spark.sql(sql);
System.out.println("3>>>>>>>>>>>>>>>" + Util.toStr(null));
System.out.println("4>>>>>>>>>>>>>>>" + Util.toStr(null));
namesDF.show();
System.out.println("5>>>>>>>>>>>>>>>" + Util.toStr(null));
结果发现,把parquet读出到运算得出结果大约7秒左右,比oracle运行速度稍慢一点点。
我的spark用的是三台linux虚拟机,一台master,两台worker。
请问有没有更好的方法,进一步提高效率?秒级的响应速度 。我用的测试数据是百万级别。[/quote]
首先group by count不要作为性能评估依据。。。其次你用SparkSQL就是要用UDF/UDAF以及要跑很久的复杂查询,否则你直接JDBC查Oracle算了。。。最后3台虚拟机。。。给个眼神你自己体会 System.out.println("0>>>>>>>>>>>>>>>" + Util.toStr(null));
Dataset<Row> jdbcDF = spark.read().format("jdbc")
.option("url", "jdbc:oracle:thin:@192.168.56.1:1521:orcl")
.option("dbtable", "testTable")
.option("user", "test")
.option("password", "test")
.option("driver", "oracle.jdbc.driver.OracleDriver")
.load();
jdbcDF.select("testcol", "testcol1").orderBy("testcol").write().parquet("hdfs://master:9000/test.parquet");
System.out.println("1>>>>>>>>>>>>>>>" + Util.toStr(null));
Dataset<Row> parquetFileDF = spark.read().parquet("hdfs://master:9000/test.parquet");
System.out.println("2>>>>>>>>>>>>>>>" + Util.toStr(null));
parquetFileDF.createOrReplaceTempView("parquetFile");
String sql = "SELECT testcol,count(*) c FROM parquetFile group by testcol order by c desc";
System.out.println("sql:"+ sql);
Dataset<Row> namesDF = spark.sql(sql);
System.out.println("3>>>>>>>>>>>>>>>" + Util.toStr(null));
System.out.println("4>>>>>>>>>>>>>>>" + Util.toStr(null));
namesDF.show();
System.out.println("5>>>>>>>>>>>>>>>" + Util.toStr(null));
结果发现,把parquet读出到运算得出结果大约7秒左右,比oracle运行速度稍慢一点点。
我的spark用的是三台linux虚拟机,一台master,两台worker。
请问有没有更好的方法,进一步提高效率?秒级的响应速度 。我用的测试数据是百万级别。