SPARK sql 执行效率不高?
# test.py
df = sqlContext \
.read \
.format("jdbc") \
.option("url", url) \
.option("dbtable", "stock_detail_collect_20151105_1130") \
.load()
df.registerTempTable("people")
countsByAge = sqlContext.sql("select stock_id, count(*) as ct from people group by stock_id order by stock_id desc")
=====================
./spark-submit --driver-class-path ../mariadb-java-client-1.3.6.jar ../test.py
以上代码执行起来没有直接在数据库(MariaDB)里执行sql语句快,然后在linux 下top命令看执行过程的时候资源使用情况,多核cpu没有全部使用,只用1个核心,100%。
问题:1.在单机环境下,就是没有直接在数据库里快?
2.要使用多核怎么处理?加--executor-cores 2 也没有用,top查看还是一样。