Optimization ideas in the Spark SQL project

Source: Internet
Author: User

Selection of storage formats:Do you take row or column-type storage? The number of times a column store is written, and the loss time is much faster when queriedselection of compression formats:Consider the compression speed and the compressed file of the partition compression can be less storage space, improve data transfer speed The default compression format in Spark is "snappy"optimization of the code:Selected high-performance operators: Foreachpartition = Partitionofrecords.foreach the benefit of getting each data partition is to save all of the partition data in the list first, We can then insert MySQL into the pstmt batch, one at a time to write the entire partition data to reuse the existing data: In the project, if you implement multiple functions at the same time (in this case there are three), in the calculation to see if there is overlap between each function of the data generated, If any, the corresponding data is extracted to generate, all the functions of the implementation can be shared (equivalent to do a cache, the intermediate data cache)optimization of parameters:Degree of parallelism: spark.sql.shuffle.partitions default is 200, configured is the number of partitions, corresponding to the number of tasks if you feel too slow to run, then you need to change this value in conf (Yarn startup) The partition field type is inferred: Spark.sql.sources.partitionColumnTypeInference.enabled is on by default, and when turned on, the system automatically guesses that the type of partition field is turned off to improve performance.

Optimization ideas in the Spark SQL project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.