From issues-return-189694-archive-asf-public=cust-asf.ponee.io@spark.apache.org Thu Apr 19 23:18:04 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 39C4E180638 for ; Thu, 19 Apr 2018 23:18:04 +0200 (CEST) Received: (qmail 28530 invoked by uid 500); 19 Apr 2018 21:18:03 -0000 Mailing-List: contact issues-help@spark.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@spark.apache.org Received: (qmail 28521 invoked by uid 99); 19 Apr 2018 21:18:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Apr 2018 21:18:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id C74A7C0430 for ; Thu, 19 Apr 2018 21:18:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -110.311 X-Spam-Level: X-Spam-Status: No, score=-110.311 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id EPih3GRhBe6W for ; Thu, 19 Apr 2018 21:18:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id B79BE5F576 for ; Thu, 19 Apr 2018 21:18:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 48EF5E0CC1 for ; Thu, 19 Apr 2018 21:18:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id E88122120A for ; Thu, 19 Apr 2018 21:18:00 +0000 (UTC) Date: Thu, 19 Apr 2018 21:18:00 +0000 (UTC) From: "Apache Spark (JIRA)" To: issues@spark.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (SPARK-24020) Sort-merge join inner range optimization MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/SPARK-24020?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D164= 44814#comment-16444814 ]=20 Apache Spark commented on SPARK-24020: -------------------------------------- User 'zecevicp' has created a pull request for this issue: https://github.com/apache/spark/pull/21109 > Sort-merge join inner range optimization > ---------------------------------------- > > Key: SPARK-24020 > URL: https://issues.apache.org/jira/browse/SPARK-24020 > Project: Spark > Issue Type: Improvement > Components: SQL > Affects Versions: 2.3.0 > Reporter: Petar Zecevic > Priority: Major > > The problem we are solving is the case where you have two big tables part= itioned by X column, but also sorted by Y column (within partitions) and yo= u need to calculate an expensive function on the joined rows. During a sort= -merge join, Spark will do cross-joins of all rows that have the same X val= ues and calculate the function's value on all of them. If the two tables ha= ve a large number of rows per X, this can result in a huge number of calcul= ations. > We hereby propose an optimization that would allow you to reduce the numb= er of matching rows per X using a range condition on Y columns of the two t= ables. Something like: > ... WHERE t1.X =3D t2.X AND t1.Y BETWEEN t2.Y - d AND t2.Y + d > The way SMJ is currently implemented, these extra conditions have no infl= uence on the number of rows (per X) being checked because these extra condi= tions are put in the same block with the function being calculated. > Here we propose a change to the sort-merge join so that, when these extra= conditions are specified, a queue is used instead of the ExternalAppendOnl= yUnsafeRowArray class. This queue would then used as a moving window across= the values from the right relation as the left row changes. You could call= this a combination of an equi-join and a theta join (we call it "sort-merg= e inner range join"). > Potential use-cases for this are joins based on spatial or temporal dista= nce calculations. > The optimization should be triggered automatically when an equi-join expr= ession is present AND lower and upper range conditions on a secondary colum= n are specified. If the tables aren't sorted by both columns, appropriate s= orts should be added. > To limit the impact of this change we also propose adding a new parameter= (tentatively named "spark.sql.join.smj.useInnerRangeOptimization") which c= ould be used to switch off the optimization entirely. > =C2=A0 -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org For additional commands, e-mail: issues-help@spark.apache.org