Skip to content

Commit 9afec95

Browse files
authored
Reenable memoization of correlated-to sets (#3371)
Not memoizing this set caused massive performance problems downstream.
1 parent e5a5d44 commit 9afec95

File tree

1 file changed

+9
-1
lines changed
  • fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades

1 file changed

+9
-1
lines changed

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/Quantifier.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ public abstract class Quantifier implements Correlated<Quantifier> {
9494
@Nonnull
9595
private final CorrelationIdentifier alias;
9696

97+
/**
98+
* As a quantifier is immutable, the correlated set can be computed lazily and then cached. This supplier
99+
* represents that cached set.
100+
*/
101+
@Nonnull
102+
private final Supplier<Set<CorrelationIdentifier>> correlatedToSupplier;
103+
97104
/**
98105
* As a quantifier is immutable, the columns that flow along the quantifier can be lazily computed.
99106
*/
@@ -577,6 +584,7 @@ public static Physical physical(@Nonnull final Reference reference,
577584

578585
protected Quantifier(@Nonnull final CorrelationIdentifier alias) {
579586
this.alias = alias;
587+
this.correlatedToSupplier = Suppliers.memoize(() -> getRangesOver().getCorrelatedTo());
580588
this.flowedColumnsSupplier = Suppliers.memoize(this::computeFlowedColumns);
581589
this.flowedValuesSupplier = Suppliers.memoize(this::computeFlowedValues);
582590
// Call debugger hook for this new quantifier.
@@ -664,7 +672,7 @@ public String toString() {
664672
@Nonnull
665673
@Override
666674
public Set<CorrelationIdentifier> getCorrelatedTo() {
667-
return getRangesOver().getCorrelatedTo();
675+
return correlatedToSupplier.get();
668676
}
669677

670678
/**

0 commit comments

Comments
 (0)