Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,20 @@ private Collection<Long> distributionPrune(
DistributionInfo distributionInfo,
boolean pruneTablesByNereids) throws AnalysisException {
if (pruneTablesByNereids) {
return nereidsPrunedTabletIds.isEmpty()
? null
: new ArrayList<>(nereidsPrunedTabletIds);
if (nereidsPrunedTabletIds.isEmpty()) {
return null;
}
// Filter to tablets belonging to this partition. Without this, the caller's
// per-partition loop in computeTabletInfo becomes O(partitionNum * globalPrunedSize)
// getTablet hash lookups (most returning null), which dominates plan time
// when both partition count and pruned tablet count are large.
List<Long> result = new ArrayList<>();
for (Long id : tabletIdsInOrder) {
if (nereidsPrunedTabletIds.contains(id)) {
result.add(id);
}
}
return result;
}
DistributionPruner distributionPruner = null;
switch (distributionInfo.getType()) {
Expand Down Expand Up @@ -918,8 +929,9 @@ private void computeTabletInfo() throws UserException {
boolean notExistsSampleAndPrunedTablets = sampleTabletIds.isEmpty() && nereidsPrunedTabletIds.isEmpty();
if (prunedTabletIds != null) {
for (Long id : prunedTabletIds) {
if (selectedTable.getTablet(id) != null) {
tablets.add(selectedTable.getTablet(id));
Tablet tablet = selectedTable.getTablet(id);
if (tablet != null) {
tablets.add(tablet);
scanTabletIds.add(id);
} else if (notExistsSampleAndPrunedTablets) {
// The tabletID specified in query does not exist in this partition, skip scan partition.
Expand Down
Loading