Loading...

New query optimization techniques in Apache Spark for Azure Synapse

New query optimization techniques in Apache Spark for Azure Synapse

The Azure Synapse Analytics team has prominent engineers enhancing and contributing back to the Apache Spark project. One of our focus areas is Spark query optimization techniques, where Microsoft has decades of experience and is making significant contributions to the Apache Spark open source engine.

 

The attachment at the bottom of this blog post will be presented at the 48th International Conference on Very Large Databases (#VLDB2022) and covers the latest developments in query optimization for Apache Spark 3. Those optimizations were developed by Microsoft engineers and are available today in the Azure Synapse runtime for Apache Spark versions 3.1 and 3.2. They are also part of the Apache Spark open source codebase.

 

The optimizations are motivated by a detailed performance analysis of Apache Spark on the TPC-DS benchmark. Based on operator level breakdown of the 20 most expensive TPC-DS queries, work has been done to identify exchange, aggregations and sort as the three most expensive operators. To bring down its cost three classes of optimizations were proposed. 

 

  1. Exchange placement: As exchange is the most expensive operator, focus was put into a new algorithm to minimize the usage of such method. In other words, a new algorithm was created to decide on the best placement of exchange operators. The algorithm takes into consideration the possibility of reusing an exchange to reduce exchanges beyond the default Apache Spark algorithm.
  2. Partial push-down: This refers to a class of optimizations where some partial computation is derived from an existing operator and pushed down the chain below an exchange. The existing operator is not eliminated, hence it is a partial pushdown.
    • Partial aggregation push-down: we introduced a new logical operator to represent local-aggregation operator and to introduce a comprehensive set of optimization rules to push down local-aggregates below all standard SQL operators. Derive local aggregates not only from group-by but also from semi-join and intersect. This allows Spark to aggregate data early and reduce the amount of data shuffled, a critical component of performance.
    • Partial push-down of semi-joins:  This is another example of an optimization which pushes down parts of an operator without eliminating it. The optimization looks at the query plan tree that is rooted at a semi-join and has multiple joins under it; and then converts some inner joins to semi-joins. It encodes a comprehensive set of conditions under which it is safe to do so.
  3. Peephole optimizations: We optimized the implementation of sorting, the third most expensive operator in spark, by re-ordering the keys where possible. Also specialized the sorting algorithm in scenarios where some keys have very few distinct values. These optimizations significantly reduce the time spent in sort on queries.

The work resulted in considerable performance benefits across the board on the reference TPC-DS workload as well as a significant reduction in query plan generation time. Please consider reading the complete paper for details on the work performed. 

 

To learn more about our previous optimization contributions to the Apache Spark open source community, please read:

 

 

 

 

Published on:

Learn more
Azure Synapse Analytics Blog articles
Azure Synapse Analytics Blog articles

Azure Synapse Analytics Blog articles

Share post:

Related posts

We're moving!

We’re moving to the Analytics on Azure Tech Community! All new Azure Synapse Analytics content will be published there. In the next few days a...

1 year ago

Upgrade to Azure Synapse runtimes for Apache Spark 3.4 & previous runtimes deprecation

It is important to stay ahead of the curve and keep services up to date. That's why we encourage all Azure Synapse customers with Apache ...

2 years ago

ADF\Synapse Analytics - Replace Columns names using Rule based mapping in Mapping data flows

In real time, the column names from source might not be uniform, some columns will have a space in it, some other columns will not. For exampl...

2 years ago

Interpreting Script activity output json with Azure Data Factory\Synapse analytics

Script activity in Azure Data Factory\ Synapse analytics is very helpful to run queries against data sources mentioned here in this document.&...

2 years ago

Synapse Connectivity Series Part #4 - Advanced network troubleshooting and network trace analysis

Continuing the series of this blog posts I would like to go more advanced on troubleshooting connectivity issues. I would like to thank also&n...

2 years ago

Boost your CICD automation for Synapse SQL Serverless by taking advantage of SSDT and SqlPackage CLI

Introduction   Azure Synapse Analytics Serverless SQL is a query service mostly used over the data in your data lake, for data discovery,...

2 years ago

Metadata-Based Ingestion in Synapse with Delta Lake

  Overview     The crucial first step in any ETL (extract, transform, load) process or data engineering program is ingestion, w...

3 years ago

Missing Fields Added to Dedicated SQL pool Diagnostic Settings Logs

Over the past year, customers have informed the team there were a set of key columns missing in the standalone Dedicated SQL pools (formerly S...

3 years ago

Using Azure DevOps with Synapse Workspaces to create hot fixes in production environments

Have you ever deployed a release to production only to find out a bug has escaped your testing process and now users are being severely impact...

3 years ago

Azure Synapse MVP Corner - March 2023

About this blog series Microsoft Most Valuable Professionals, or MVPs, are technology experts who passionately share their knowledge with the ...

3 years ago

Newsletter

Get the latest Dynamics 365 and Power Platform content in your inbox

A curated digest of community blogs, product news, videos, and podcasts — delivered without the noise.

Weekly updates Unsubscribe anytime Fresh community picks
We use your email only for the newsletter and you can unsubscribe at any time.
By subscribing, you agree to the privacy policy.