Spark SQL性能优化
2016-05-13 14:43
274 查看
Spark SQL性能优化
性能优化参数
针对Spark SQL 性能调优参数如下:代码示例
import java.util.List; import org.apache.spark.SparkConf; import org.apache.spark.api.java.JavaSparkContext; import org.apache.spark.sql.api.java.JavaSQLContext; import org.apache.spark.sql.api.java.Row; import org.apache.spark.sql.hive.api.java.JavaHiveContext; public class PerformanceTuneDemo { public static void main(String[] args) { SparkConf conf = new SparkConf().setAppName("simpledemo").setMaster("local"); conf.set("spark.sql.codegen", "false"); conf.set("spark.sql.inMemoryColumnarStorage.compressed", "false"); conf.set("spark.sql.inMemoryColumnarStorage.batchSize", "1000"); conf.set("spark.sql.parquet.compression.codec", "snappy"); JavaSparkContext sc = new JavaSparkContext(conf); JavaSQLContext sqlCtx = new JavaSQLContext(sc); JavaHiveContext hiveCtx = new JavaHiveContext(sc); List<Row> result = hiveCtx.sql("SELECT foo,bar,name from pokes2 limit 10").collect(); for (Row row : result) { System.out.println(row.getString(0) + "," + row.getString(1) + "," + row.getString(2)); } } }
Beeline 命令行设置优化参数
beeline> set spark.sql.codegen=true; SET spark.sql.codegen=true spark.sql.codegen=true Time taken: 1.196 seconds
重要参数说明
spark.sql.codegen Spark SQL在每次执行次,先把SQL查询编译JAVA字节码。针对执行时间长的SQL查询或频繁执行的SQL查询,此配置能加快查询速度,因为它产生特殊的字节码去执行。但是针对很短(1 - 2秒)的临时查询,这可能增加开销,因为它必须先编译每一个查询。spark.sql.inMemoryColumnarStorage.batchSize:
When caching SchemaRDDs, Spark SQL groups together the records in the RDD in batches of the size given by this option (default: 1000), and compresses each batch. Very small batch sizes lead to low compression, but on the other hand very large sizes can also
be problematic, as each batch might be too large to build up in memory.
相关文章推荐
- SQL测试题
- oracle的多字段排序去重Row_Number() Over(Partition By A, B Order By C Desc)
- Windows下mysql修改root密码的4种方法
- Elasticsearch mysql 增量同步
- redis设置密码
- MYSQL必知必会读书笔记 第二十六章 管理事务处理
- MySQL索引注意的几个地方
- redis常用命令与使用配置
- SqlBulkCopy对象和SqlDataApter的Update方法
- 【基础】Oracle 表空间和数据文件
- 解决mariadb识别字母大小敏感问题
- 本地msdos(cmd)下输入mysql命令提示:‘mysql’不是内部或外部命令,也不是可运行的程序或批处理文件
- MySQL性能优化二十大实战经验
- ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var mysql 启动不了
- memcache安装及使用详解
- 第二章 mybatis使用注解实现in查询(mysql)
- 利用redis + lua解决抢红包高并发的问题
- MYSQL必知必会读书笔记 第二十五章 使用触发器
- 数据库缓存字节数超过128K
- MySQL高可用架构在业务层面的分析研究