Package io.trino.cost

Class CostCalculatorWithEstimatedExchanges

java.lang.Object
io.trino.cost.CostCalculatorWithEstimatedExchanges
All Implemented Interfaces:
CostCalculator

@ThreadSafe public class CostCalculatorWithEstimatedExchanges extends Object implements CostCalculator
A wrapper around CostCalculator that estimates ExchangeNodes cost.

Certain rules (e.g. ReorderJoins and DetermineJoinDistributionType) are run before exchanges are added to a plan. This cost calculator adds the implied costs for the exchanges that will be added later. It is needed to account for the differences in exchange costs for different types of joins.

  • Constructor Details

    • CostCalculatorWithEstimatedExchanges

      @Inject public CostCalculatorWithEstimatedExchanges(CostCalculator costCalculator, TaskCountEstimator taskCountEstimator)
  • Method Details

    • calculateCost

      public PlanCostEstimate calculateCost(PlanNode node, StatsProvider stats, CostProvider sourcesCosts, Session session)
      Description copied from interface: CostCalculator
      Calculates cumulative cost of a node.
      Specified by:
      calculateCost in interface CostCalculator
      Parameters:
      node - The node to compute cost for.
      stats - The stats provider for node's stats and child nodes' stats, to be used if stats are needed to compute cost for the node
    • calculateRemoteGatherCost

      public static LocalCostEstimate calculateRemoteGatherCost(double inputSizeInBytes)
    • calculateRemoteRepartitionCost

      public static LocalCostEstimate calculateRemoteRepartitionCost(double inputSizeInBytes)
    • calculateLocalRepartitionCost

      public static LocalCostEstimate calculateLocalRepartitionCost(double inputSizeInBytes)
    • calculateRemoteReplicateCost

      public static LocalCostEstimate calculateRemoteReplicateCost(double inputSizeInBytes, int destinationTaskCount)
    • calculateJoinCostWithoutOutput

      public static LocalCostEstimate calculateJoinCostWithoutOutput(PlanNode probe, PlanNode build, StatsProvider stats, boolean replicated, int estimatedSourceDistributedTaskCount)
    • adjustReplicatedJoinLocalExchangeCost

      public static LocalCostEstimate adjustReplicatedJoinLocalExchangeCost(PlanNode build, StatsProvider stats, boolean replicated, int estimatedSourceDistributedTaskCount)
    • calculateJoinInputCost

      public static LocalCostEstimate calculateJoinInputCost(PlanNode probe, PlanNode build, StatsProvider stats, boolean replicated, int estimatedSourceDistributedTaskCount)