-
-
Save msirek/43e40e010eeb80b983db96892e22b7e6 to your computer and use it in GitHub Desktop.
Detect scans from regional tables that can be satisfied in the local region.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (s *ScanPrivate) IsLocalOnly(md *opt.Metadata, evalCtx *eval.Context) bool { | |
tab := md.Table(s.Table) | |
tabMeta := md.TableMeta(s.Table) | |
index := tabMeta.Table.Index(s.Index) | |
homeRegion, hasHomeRegion := tab.HomeRegion() | |
prefixSorter, ok := tabMeta.IndexPartitionLocality(index.Ordinal(), index, evalCtx) | |
localRegion, hasLocalRegion := evalCtx.GetLocalRegion() | |
if s.LocalityOptimized { | |
return true | |
} else if tab.IsGlobalTable() { | |
return true | |
} else if !ok && !hasHomeRegion { | |
// Not regional by row or regional by table. | |
return false | |
} else if hasHomeRegion { | |
if !hasLocalRegion || homeRegion != localRegion { | |
return false | |
} | |
return true | |
} else if !hasLocalRegion || s.Constraint == nil { | |
return false | |
} else if s.Constraint.HasRemoteSpans(prefixSorter) { | |
return false | |
} | |
return true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment