From d405f06ab52e328381491f25e5b304de4d128186 Mon Sep 17 00:00:00 2001 From: xufei Date: Sun, 23 May 2021 19:59:18 +0800 Subject: [PATCH] planner: do not pushdown join to TiFlash if left condition/right condition is not empty while the join type is not left/right (#24846) * support cross broadcast join * save work * save work * support push down cartesian join to tiflash * enable cartesian push down by default * refine * fix * fix * fix ci --- go.sum | 4 ---- planner/core/exhaust_physical_plans.go | 4 ++++ store/tikv/batch_request_sender.go | 1 + store/tikv/region_cache.go | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/go.sum b/go.sum index 1ccd88dc72058..adf6817e4fa6a 100644 --- a/go.sum +++ b/go.sum @@ -460,8 +460,6 @@ github.com/pingcap/kvproto v0.0.0-20191211054548-3c6b38ea5107/go.mod h1:WWLmULLO github.com/pingcap/kvproto v0.0.0-20200411081810-b85805c9476c/go.mod h1:IOdRDPLyda8GX2hE/jO7gqaCV/PNFh8BZQCQZXfIOqI= github.com/pingcap/kvproto v0.0.0-20200810113304-6157337686b1/go.mod h1:IOdRDPLyda8GX2hE/jO7gqaCV/PNFh8BZQCQZXfIOqI= github.com/pingcap/kvproto v0.0.0-20210219064844-c1844a4775d6/go.mod h1:IOdRDPLyda8GX2hE/jO7gqaCV/PNFh8BZQCQZXfIOqI= -github.com/pingcap/kvproto v0.0.0-20210308063835-39b884695fb8 h1:t72qxPxunoKykkAuO5glpWGdoP+RmvKvX0lvmyFV0fI= -github.com/pingcap/kvproto v0.0.0-20210308063835-39b884695fb8/go.mod h1:IOdRDPLyda8GX2hE/jO7gqaCV/PNFh8BZQCQZXfIOqI= github.com/pingcap/kvproto v0.0.0-20210507122400-22bdfdb2e4cc h1:/puc8geNAmexWtrumtsbIpNZKYCmbx7hDVrkmFcOFjg= github.com/pingcap/kvproto v0.0.0-20210507122400-22bdfdb2e4cc/go.mod h1:IOdRDPLyda8GX2hE/jO7gqaCV/PNFh8BZQCQZXfIOqI= github.com/pingcap/log v0.0.0-20191012051959-b742a5d432e9/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8= @@ -476,8 +474,6 @@ github.com/pingcap/sysutil v0.0.0-20210221112134-a07bda3bde99/go.mod h1:EB/852NM github.com/pingcap/tidb-dashboard v0.0.0-20210312062513-eef5d6404638/go.mod h1:OzFN8H0EDMMqeulPhPMw2i2JaiZWOKFQ7zdRPhENNgo= github.com/pingcap/tidb-tools v4.0.9-0.20201127090955-2707c97b3853+incompatible h1:ceznmu/lLseGHP/jKyOa/3u/5H3wtLLLqkH2V3ssSjg= github.com/pingcap/tidb-tools v4.0.9-0.20201127090955-2707c97b3853+incompatible/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM= -github.com/pingcap/tipb v0.0.0-20210326161441-1164ca065d1b h1:sZHSH0mh8PcRbmZlsIqP7CEwnfFuBpmkGt5i9JStLWA= -github.com/pingcap/tipb v0.0.0-20210326161441-1164ca065d1b/go.mod h1:nsEhnMokcn7MRqd2J60yxpn/ac3ZH8A6GOJ9NslabUo= github.com/pingcap/tipb v0.0.0-20210522031117-09a46c1aff57 h1:9+GOQcAJ5xZkHe5u4znRB/3ldUpUJSBmoJO5UMTtUtU= github.com/pingcap/tipb v0.0.0-20210522031117-09a46c1aff57/go.mod h1:nsEhnMokcn7MRqd2J60yxpn/ac3ZH8A6GOJ9NslabUo= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= diff --git a/planner/core/exhaust_physical_plans.go b/planner/core/exhaust_physical_plans.go index 9da3d74d64ccd..56ffc85cae4f0 100644 --- a/planner/core/exhaust_physical_plans.go +++ b/planner/core/exhaust_physical_plans.go @@ -1756,6 +1756,10 @@ func (p *LogicalJoin) tryToGetMppHashJoin(prop *property.PhysicalProperty, useBC return nil } } + if (len(p.LeftConditions) != 0 && p.JoinType != LeftOuterJoin) || (len(p.RightConditions) != 0 && p.JoinType != RightOuterJoin) { + return nil + } + if prop.PartitionTp == property.BroadcastType { return nil } diff --git a/store/tikv/batch_request_sender.go b/store/tikv/batch_request_sender.go index 3f6e552195c04..dea07676c3ccb 100644 --- a/store/tikv/batch_request_sender.go +++ b/store/tikv/batch_request_sender.go @@ -25,6 +25,7 @@ import ( "google.golang.org/grpc/status" ) +// RegionInfo contains region related information for batchCopTask type RegionInfo struct { Region RegionVerID Meta *metapb.Region diff --git a/store/tikv/region_cache.go b/store/tikv/region_cache.go index 6d1a64be78adb..8add2112bcd11 100644 --- a/store/tikv/region_cache.go +++ b/store/tikv/region_cache.go @@ -536,6 +536,7 @@ func (c *RegionCache) GetTiKVRPCContext(bo *Backoffer, id RegionVerID, replicaRe }, nil } +// GetAllValidTiFlashStores returns the store ids of all valid TiFlash stores, the store id of currentStore is always the first one func (c *RegionCache) GetAllValidTiFlashStores(id RegionVerID, currentStore *Store) []uint64 { allStores := make([]uint64, 0, 1) allStores = append(allStores, currentStore.storeID)